Allow upgrade page to render for multi-workspace flow#91551
Conversation
The NotFoundPage guard on WorkspaceUpgradePage only checked canEditWorkspaceSettings(policy), which returns false when policy is undefined. This blocked the multi-workspace upgrade path where no policyID is provided. Adding a canModifyPlan check lets users with multiple workspaces reach the existing workspace selection UI. Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
| // or editors on Submit policies). `canPerformUpgrade` (strict admin) still controls | ||
| // whether the upgrade button is active, so editors see the intro but can't upgrade. | ||
| if (!canEditWorkspaceSettings(policy)) { | ||
| if (!canEditWorkspaceSettings(policy) && !canModifyPlan(ownerPolicies, policy)) { |
There was a problem hiding this comment.
@MelvinBot dry up code. If policy doesn't exist, no need to trigger canEditWorkspaceSettings as redundant. Also update above comment accordingly if it's wrong.
There was a problem hiding this comment.
Dried up the condition using a ternary: when policy exists, only canEditWorkspaceSettings is needed (it's a superset of canModifyPlan's isPolicyAdmin check); when no policy exists, only canModifyPlan matters (since canEditWorkspaceSettings would always return false). Updated the comment to reflect the two distinct paths.
…e checks When policy exists, only canEditWorkspaceSettings matters (superset of canModifyPlan's isPolicyAdmin check). When no policy exists (multi-workspace flow), only canModifyPlan matters since canEditWorkspaceSettings would always return false. Updated comment to reflect the distinct logic paths. Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
| // gate access to owners of multiple policies via canModifyPlan. | ||
| // `canPerformUpgrade` (strict admin) still controls whether the upgrade button is active, | ||
| // so editors see the intro but can't upgrade. | ||
| if (!(policy ? canEditWorkspaceSettings(policy) : canModifyPlan(ownerPolicies, policy))) { |
There was a problem hiding this comment.
@MelvinBot reuse canPerformUpgrade. No need to recompute canModifyPlan.
Also, condition ? !A : !B is better format than !(condition ? A : B)
There was a problem hiding this comment.
Done — reusing the memoized canPerformUpgrade instead of recomputing canModifyPlan, and switched to the condition ? !A : !B format.
Reuse the memoized canPerformUpgrade instead of recomputing canModifyPlan, and use `condition ? !A : !B` format instead of `!(condition ? A : B)`. Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
| // When a specific policy is loaded, gate access to users who can edit its settings | ||
| // (admins, or editors on Submit policies). When no policy exists (multi-workspace flow), | ||
| // gate access to owners of multiple policies via canModifyPlan. | ||
| // `canPerformUpgrade` (strict admin) still controls whether the upgrade button is active, | ||
| // so editors see the intro but can't upgrade. |
There was a problem hiding this comment.
@MelvinBot Simplify this comment. It's too long. And it should explain "why", NOT "what" is this code for. The code already explains enough for "what".
There was a problem hiding this comment.
Simplified to a two-line comment that explains why — editors can view but only admins can upgrade, hence the split between access gating and the upgrade action.
Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
|
@MelvinBot add tests steps and check off all items. They're verified. |
|
Updated the PR description: added test steps (Tests, Offline, QA) and checked off all checklist items. |
|
@MelvinBot mark as ready for review |
|
Marked as ready for review. |
|
@aimane-chnaif Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid.movAndroid: mWeb ChromeiOS: HybridAppios.moviOS: mWeb SafariMacOS: Chrome / Safariweb.mov |
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #91492 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
Explanation of Change
When a user with 2+ paid workspaces clicks "Upgrade to Control" from the Subscription page,
SubscriptionPlanCardActionButtonnavigates toworkspaces/upgradewithout apolicyID. TheWorkspaceUpgradePageguard (canEditWorkspaceSettings(policy)) then returnsfalsefor theundefinedpolicy and rendersNotFoundPage.This PR adds a fallback check using
canModifyPlan(ownerPolicies, policy), which already exists and returnstruewhen there is no specific policy but the user owns multiple upgradeable workspaces. This lets users reach the existing workspace selection UI on the upgrade page instead of hitting the "Not here" dead end.Fixed Issues
$ #91492
PROPOSAL: #91492 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari