From a3f5a303c19f37eeab3346bd3f04d0a42bf4448c Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 27 Jun 2024 15:16:28 +0700 Subject: [PATCH 1/2] fix: Prevent requesting money from domain emails --- src/libs/OptionsListUtils.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 24471b7f0140..9e6adc0dfc06 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -175,6 +175,7 @@ type GetOptionsConfig = { recentlyUsedPolicyReportFieldOptions?: string[]; transactionViolations?: OnyxCollection; includeInvoiceRooms?: boolean; + includeDomainEmail?: boolean; }; type GetUserToInviteConfig = { @@ -1782,6 +1783,7 @@ function getOptions( policyReportFieldOptions = [], recentlyUsedPolicyReportFieldOptions = [], includeInvoiceRooms = false, + includeDomainEmail = false, }: GetOptionsConfig, ): Options { if (includeCategories) { @@ -1913,6 +1915,10 @@ function getOptions( return; } + if (Str.isDomainEmail(option.login ?? '') && !includeDomainEmail) { + return; + } + if (isThread && !includeThreads) { return; } @@ -1937,7 +1943,9 @@ function getOptions( return option; }); - const havingLoginPersonalDetails = includeP2P ? options.personalDetails.filter((detail) => !!detail?.login && !!detail.accountID && !detail?.isOptimisticPersonalDetail) : []; + const havingLoginPersonalDetails = includeP2P + ? options.personalDetails.filter((detail) => !!detail?.login && !!detail.accountID && !detail?.isOptimisticPersonalDetail && (includeDomainEmail || !Str.isDomainEmail(detail.login))) + : []; let allPersonalDetailsOptions = havingLoginPersonalDetails; if (sortPersonalDetailsByAlphaAsc) { @@ -2186,6 +2194,7 @@ function getFilteredOptions( policyReportFieldOptions: string[] = [], recentlyUsedPolicyReportFieldOptions: string[] = [], includeInvoiceRooms = false, + includeDomainEmail = false, ) { return getOptions( {reports, personalDetails}, @@ -2213,6 +2222,7 @@ function getFilteredOptions( policyReportFieldOptions, recentlyUsedPolicyReportFieldOptions, includeInvoiceRooms, + includeDomainEmail, }, ); } From b9a693888f0fc245bd81edbb45dd8bfbfe500b4f Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 2 Jul 2024 15:44:41 +0700 Subject: [PATCH 2/2] fix move check to report uitls --- src/libs/OptionsListUtils.ts | 8 ++------ src/libs/ReportUtils.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 9e6adc0dfc06..1384f73a1f8f 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1866,6 +1866,8 @@ function getOptions( isInFocusMode: false, excludeEmptyChats: false, includeSelfDM, + login: option.login, + includeDomainEmail, }); }); @@ -1915,10 +1917,6 @@ function getOptions( return; } - if (Str.isDomainEmail(option.login ?? '') && !includeDomainEmail) { - return; - } - if (isThread && !includeThreads) { return; } @@ -2194,7 +2192,6 @@ function getFilteredOptions( policyReportFieldOptions: string[] = [], recentlyUsedPolicyReportFieldOptions: string[] = [], includeInvoiceRooms = false, - includeDomainEmail = false, ) { return getOptions( {reports, personalDetails}, @@ -2222,7 +2219,6 @@ function getFilteredOptions( policyReportFieldOptions, recentlyUsedPolicyReportFieldOptions, includeInvoiceRooms, - includeDomainEmail, }, ); } diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index cca52ac37c9d..a806217329bb 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5383,6 +5383,8 @@ function shouldReportBeInOptionList({ excludeEmptyChats, doesReportHaveViolations, includeSelfDM = false, + login, + includeDomainEmail = false, }: { report: OnyxEntry; currentReportId: string; @@ -5392,6 +5394,8 @@ function shouldReportBeInOptionList({ excludeEmptyChats: boolean; doesReportHaveViolations: boolean; includeSelfDM?: boolean; + login?: string; + includeDomainEmail?: boolean; }) { const isInDefaultMode = !isInFocusMode; // Exclude reports that have no data because there wouldn't be anything to show in the option item. @@ -5495,6 +5499,11 @@ function shouldReportBeInOptionList({ if (isSelfDM(report)) { return includeSelfDM; } + + if (Str.isDomainEmail(login ?? '') && !includeDomainEmail) { + return false; + } + const parentReportAction = ReportActionsUtils.getParentReportAction(report); // Hide chat threads where the parent message is pending removal