Repository navigation
Allow to create reports in submit2026 workspaces #92241
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
f68b2a5
cacdab4
b7e6699
558cf40
0ba2993
25ef402
6f2a05a
1a838cc
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 |
|---|---|---|
|
|
@@ -2113,6 +2113,27 @@ function getGroupPaidPoliciesWithExpenseChatEnabled(policies: OnyxCollection<Pol | |
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the group workspaces where the user can create a report: paid (Team/Corporate) workspaces, | ||
| * plus Submit workspaces when the SUBMIT_2026 beta is enabled. Submit workspaces are free but still | ||
| * support report creation, so they belong here even though they're excluded from | ||
| * `getGroupPaidPoliciesWithExpenseChatEnabled`. | ||
| * | ||
| * @param isSubmit2026BetaEnabled - Prefer `isBetaEnabled(CONST.BETAS.SUBMIT_2026)` from `usePermissions()`, not raw betas from Onyx. | ||
| */ | ||
| function getGroupPoliciesWhereReportCanBeCreated(policies: OnyxCollection<Policy> | null, isSubmit2026BetaEnabled: boolean, currentUserLogin?: string) { | ||
| if (isEmptyObject(policies)) { | ||
| return CONST.EMPTY_ARRAY; | ||
| } | ||
| return Object.values(policies).filter( | ||
| (policy): policy is Policy => | ||
| !!policy?.isPolicyExpenseChatEnabled && | ||
| !policy?.isJoinRequestPending && | ||
| (isPaidGroupPolicy(policy) || canAccessSubmitWorkspaceFeatures(policy, isSubmit2026BetaEnabled)) && | ||
| shouldShowPolicy(policy, false, currentUserLogin), | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * This method checks if the active policy has expense chat enabled and is a paid group policy. | ||
| * If true, it returns the active policy itself, else it returns the first policy from groupPoliciesWithChatEnabled. | ||
|
|
@@ -2121,7 +2142,7 @@ function getGroupPaidPoliciesWithExpenseChatEnabled(policies: OnyxCollection<Pol | |
| * and the user would be taken to the workspace selection page. | ||
| */ | ||
| function getDefaultChatEnabledPolicy(groupPoliciesWithChatEnabled: Array<OnyxInputOrEntry<Policy>>, activePolicy?: OnyxInputOrEntry<Policy> | null): OnyxInputOrEntry<Policy> | undefined { | ||
| if (activePolicy && activePolicy.isPolicyExpenseChatEnabled && isPaidGroupPolicy(activePolicy)) { | ||
| if (activePolicy && activePolicy.isPolicyExpenseChatEnabled && isGroupPolicy(activePolicy)) { | ||
|
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.
When the active workspace is a Submit policy but the user is not in Useful? React with 👍 / 👎.
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. No need since users won't be able to create the workspace if they are not in the beta 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.
When Useful? React with 👍 / 👎. |
||
| return activePolicy; | ||
| } | ||
|
|
||
|
|
@@ -2495,6 +2516,7 @@ export { | |
| areSettingsInErrorFields, | ||
| settingsPendingAction, | ||
| getGroupPaidPoliciesWithExpenseChatEnabled, | ||
| getGroupPoliciesWhereReportCanBeCreated, | ||
| getDefaultChatEnabledPolicy, | ||
| getForwardsToAccount, | ||
| getSubmitToAccountID, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; | |
| import {createNewReport} from '@libs/actions/Report'; | ||
| import getCreateReportRoute, {getReportsRootRoute, navigateToCreateReportWorkspaceSelection} from '@libs/Navigation/helpers/getCreateReportRoute'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import {getDefaultChatEnabledPolicy, isPaidGroupPolicy, shouldShowPolicy} from '@libs/PolicyUtils'; | ||
| import {getDefaultChatEnabledPolicy, isGroupPolicy, shouldShowPolicy} from '@libs/PolicyUtils'; | ||
| import {hasViolations as hasViolationsReportUtils} from '@libs/ReportUtils'; | ||
| import isOnSearchMoneyRequestReportPage from '@navigation/helpers/isOnSearchMoneyRequestReportPage'; | ||
| import FABFocusableMenuItem from '@pages/inbox/sidebar/FABPopoverContent/FABFocusableMenuItem'; | ||
|
|
@@ -30,7 +30,7 @@ const chatEnabledPaidGroupPoliciesSelector = (policies: OnyxCollection<OnyxTypes | |
| } | ||
| const result: OnyxTypes.Policy[] = []; | ||
| for (const policy of Object.values(policies)) { | ||
| if (!policy?.isPolicyExpenseChatEnabled || policy?.isJoinRequestPending || !isPaidGroupPolicy(policy) || !shouldShowPolicy(policy, false, currentUserLogin)) { | ||
| if (!policy?.isPolicyExpenseChatEnabled || policy?.isJoinRequestPending || !isGroupPolicy(policy) || !shouldShowPolicy(policy, false, currentUserLogin)) { | ||
|
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.
This FAB-specific selector now includes every Submit workspace because Useful? React with 👍 / 👎.
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. No need since users won't be able to create the workspace if they are not in the beta |
||
| continue; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ CLEAN-REACT-PATTERNS-0 (docs)
React Compiler is enabled and this file compiles successfully. The
useCallbackwrapping the selector is redundant because the compiler automatically memoizes closures based on their captured variables (isSubmit2026BetaEnabled,email).Remove the
useCallbackwrapper and define the selector as a plain function expression:Reviewed at: f68b2a5 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed