-
Notifications
You must be signed in to change notification settings - Fork 4k
[No QA]: Create a list of restricted login #62079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1693,6 +1693,22 @@ 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. | ||
| */ | ||
| function getRestrictedLogins(config: GetOptionsConfig, options: OptionList, canShowManagerMcTest: boolean): Record<string, boolean> { | ||
| const userHasReportWithManagerMcTest = Object.values(options.reports).some((report) => isManagerMcTestReport(report)); | ||
| return { | ||
| [CONST.EMAIL.MANAGER_MCTEST]: | ||
| !canShowManagerMcTest || | ||
| (getIsUserSubmittedExpenseOrScannedReceipt() && !userHasReportWithManagerMcTest) || | ||
| !Permissions.isBetaEnabled(CONST.BETAS.NEWDOT_MANAGER_MCTEST, config.betas) || | ||
| isUserInvitedToWorkspace(), | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Options are reports and personal details. This function filters out the options that are not valid to be displayed. | ||
| */ | ||
|
|
@@ -1711,18 +1727,13 @@ function getValidOptions( | |
| ...config | ||
| }: GetOptionsConfig = {}, | ||
| ): Options { | ||
| const userHasReportWithManagerMcTest = Object.values(options.reports).some((report) => isManagerMcTestReport(report)); | ||
| const restrictedLogins = getRestrictedLogins(config, options, canShowManagerMcTest); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if we should pass down
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its a bit misleading to pass it as
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. canShowManagerMcTest is a flag to mark whether ManagerMcTest should be displayed or not in that place. For example, we only expect that ManagerMcTest displays on screen 1, then in screen 1 we will pass canShowManagerMcTest is true. But it doesn't mean that if canShowManagerMcTest is true, we will always display the ManagerMcTest option, we still need to check other conditions. Note that It is "canShow" not "shouldShow" |
||
|
|
||
| // Gather shared configs: | ||
| const loginsToExclude: Record<string, boolean> = { | ||
| [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.isBetaEnabled(CONST.BETAS.NEWDOT_MANAGER_MCTEST, 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 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.