From e363c52ca80b9d6d6c4f269224f4ac87e2d75f69 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Thu, 15 May 2025 14:33:32 +0700 Subject: [PATCH 1/4] create-a-list-of-restricted-login --- src/libs/OptionsListUtils.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 5dfb9d1bfe78..50f397b98707 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1689,6 +1689,17 @@ function getValidPersonalDetailOptions( return personalDetailsOptions; } +function getRestrictedLogins(config: GetOptionsConfig, options: OptionList, canShowManagerMcTest: boolean): Record { + const userHasReportWithManagerMcTest = Object.values(options.reports).some((report) => isManagerMcTestReport(report)); + return { + [CONST.EMAIL.MANAGER_MCTEST]: + !canShowManagerMcTest || + (getIsUserSubmittedExpenseOrScannedReceipt() && !userHasReportWithManagerMcTest) || + !Permissions.canUseManagerMcTest(config.betas) || + isUserInvitedToWorkspace(), + }; +} + /** * Options are reports and personal details. This function filters out the options that are not valid to be displayed. */ @@ -1707,18 +1718,13 @@ function getValidOptions( ...config }: GetOptionsConfig = {}, ): Options { - const userHasReportWithManagerMcTest = Object.values(options.reports).some((report) => isManagerMcTestReport(report)); + const restrictedLogins = getRestrictedLogins(config, options, canShowManagerMcTest); // Gather shared configs: const loginsToExclude: Record = { [CONST.EMAIL.NOTIFICATIONS]: true, ...excludeLogins, - // Exclude Manager McTest if selection is made from Create or Submit flow - [CONST.EMAIL.MANAGER_MCTEST]: - !canShowManagerMcTest || - (getIsUserSubmittedExpenseOrScannedReceipt() && !userHasReportWithManagerMcTest) || - !Permissions.canUseManagerMcTest(config.betas) || - isUserInvitedToWorkspace(), + ...restrictedLogins, }; // If we're including selected options from the search results, we only want to exclude them if the search input is empty // This is because on certain pages, we show the selected options at the top when the search input is empty From 89721754b5b8b1138c85936a51923f9f65483602 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Wed, 4 Jun 2025 14:42:36 +0700 Subject: [PATCH 2/4] main --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index eeb73ca1f3ca..5271a4ae97f9 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit eeb73ca1f3ca1c13b144b7b169b17dd82c76ea71 +Subproject commit 5271a4ae97f95f32d60b68852f38dacc7770fc94 From a22ddc577b80468055b271aa0343ef53751c9dbd Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Wed, 4 Jun 2025 23:21:06 +0700 Subject: [PATCH 3/4] add description --- src/libs/OptionsListUtils.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 1e6c3ac257c5..fe5dad1596b1 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1693,6 +1693,13 @@ function getValidPersonalDetailOptions( return personalDetailsOptions; } +/** + * Returns a list of logins that should be restricted (i.e., hidden or excluded in the UI) + * based on dynamic business logic and feature flags. + * + * Centralizes restriction logic to avoid scattering conditions across the codebase. + * Add new restricted accounts by extending the returned object. + */ function getRestrictedLogins(config: GetOptionsConfig, options: OptionList, canShowManagerMcTest: boolean): Record { const userHasReportWithManagerMcTest = Object.values(options.reports).some((report) => isManagerMcTestReport(report)); return { From e9ab41d2c6c7ada30e01b8e12eeb787751f987a5 Mon Sep 17 00:00:00 2001 From: DylanDylann Date: Wed, 4 Jun 2025 23:21:58 +0700 Subject: [PATCH 4/4] add description --- src/libs/OptionsListUtils.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index fe5dad1596b1..5af61cb698e2 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1696,9 +1696,7 @@ function getValidPersonalDetailOptions( /** * Returns a list of logins that should be restricted (i.e., hidden or excluded in the UI) * based on dynamic business logic and feature flags. - * * Centralizes restriction logic to avoid scattering conditions across the codebase. - * Add new restricted accounts by extending the returned object. */ function getRestrictedLogins(config: GetOptionsConfig, options: OptionList, canShowManagerMcTest: boolean): Record { const userHasReportWithManagerMcTest = Object.values(options.reports).some((report) => isManagerMcTestReport(report));