From 6633280020bf0fe0bfe25fca7497038f8e17d097 Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Mon, 22 Jan 2024 15:36:15 -0800 Subject: [PATCH 1/5] update comment --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 78086c354de0..8e1826637c56 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -571,7 +571,7 @@ function getPolicyName(report: OnyxEntry | undefined | EmptyObject, retu const parentReport = getRootParentReport(report); - // Public rooms send back the policy name with the reportSummary, + // Rooms send back the policy name with the reportSummary, // since they can also be accessed by people who aren't in the workspace // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const policyName = finalPolicy?.name || report?.policyName || report?.oldPolicyName || parentReport?.oldPolicyName || noPolicyFound; From 826a937482a3fe73807fcf5bb0ce86edc0a41ffb Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Tue, 23 Jan 2024 08:35:43 -0800 Subject: [PATCH 2/5] add ReportUtils.canInviteToReport --- src/libs/ReportUtils.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 8e1826637c56..8ced1596a274 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5,6 +5,7 @@ import lodashEscape from 'lodash/escape'; import lodashFindLastIndex from 'lodash/findLastIndex'; import lodashIntersection from 'lodash/intersection'; import lodashIsEqual from 'lodash/isEqual'; +import lodashIsEmpty from 'lodash/isEmpty'; import type {OnyxCollection, OnyxEntry, OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; @@ -968,6 +969,15 @@ function canCreateTaskInReport(report: OnyxEntry): boolean { return true; } +/** + * Returns whether it's possible to invite to a report. + * Only chat reports that aren't DMs can be invited to. (threads in DMs are eligible for invites) + * + */ +function canInviteToReport(report: OnyxEntry): boolean { + return isChatReport(report) && (!isDM(report) || !lodashIsEmpty(getParentReport(report))); +} + /** * Returns true if there are any Expensify accounts (i.e. with domain 'expensify.com') in the set of accountIDs * by cross-referencing the accountIDs with personalDetails. From bac2b7393c417674cf61091c81c93c3c34a9e55e Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Tue, 23 Jan 2024 08:35:59 -0800 Subject: [PATCH 3/5] allow invites in threads in DMs --- src/pages/ReportDetailsPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ReportDetailsPage.js b/src/pages/ReportDetailsPage.js index ff9ed62c6a65..5319b57faa85 100644 --- a/src/pages/ReportDetailsPage.js +++ b/src/pages/ReportDetailsPage.js @@ -123,7 +123,7 @@ function ReportDetailsPage(props) { } }, }); - } else if (isUserCreatedPolicyRoom && (!participants.length || !isPolicyMember) && !props.report.parentReportID) { + } else if (ReportUtils.canInviteToReport(props.report)) { items.push({ key: CONST.REPORT_DETAILS_MENU_ITEM.INVITE, translationKey: 'common.invite', From 68d0308bd9440a4ede8b9ce5b2359705feec9907 Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Tue, 23 Jan 2024 08:37:00 -0800 Subject: [PATCH 4/5] remove unused --- src/libs/ReportUtils.ts | 9 --------- src/pages/ReportDetailsPage.js | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 8ced1596a274..82dc0e92f771 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -969,15 +969,6 @@ function canCreateTaskInReport(report: OnyxEntry): boolean { return true; } -/** - * Returns whether it's possible to invite to a report. - * Only chat reports that aren't DMs can be invited to. (threads in DMs are eligible for invites) - * - */ -function canInviteToReport(report: OnyxEntry): boolean { - return isChatReport(report) && (!isDM(report) || !lodashIsEmpty(getParentReport(report))); -} - /** * Returns true if there are any Expensify accounts (i.e. with domain 'expensify.com') in the set of accountIDs * by cross-referencing the accountIDs with personalDetails. diff --git a/src/pages/ReportDetailsPage.js b/src/pages/ReportDetailsPage.js index 5319b57faa85..ff9ed62c6a65 100644 --- a/src/pages/ReportDetailsPage.js +++ b/src/pages/ReportDetailsPage.js @@ -123,7 +123,7 @@ function ReportDetailsPage(props) { } }, }); - } else if (ReportUtils.canInviteToReport(props.report)) { + } else if (isUserCreatedPolicyRoom && (!participants.length || !isPolicyMember) && !props.report.parentReportID) { items.push({ key: CONST.REPORT_DETAILS_MENU_ITEM.INVITE, translationKey: 'common.invite', From bb1866457b28af6d547468f07df3da7b26412ca1 Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Fri, 26 Jan 2024 12:02:17 -0800 Subject: [PATCH 5/5] remove unused --- src/libs/ReportUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 82dc0e92f771..8e1826637c56 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5,7 +5,6 @@ import lodashEscape from 'lodash/escape'; import lodashFindLastIndex from 'lodash/findLastIndex'; import lodashIntersection from 'lodash/intersection'; import lodashIsEqual from 'lodash/isEqual'; -import lodashIsEmpty from 'lodash/isEmpty'; import type {OnyxCollection, OnyxEntry, OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import type {ValueOf} from 'type-fest';