Repository navigation
fix: onboarding back button redirects to blank modal for private-domain VSB/SMB #95001
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
a9d457b
b15e80b
9146026
e5aca4c
8773544
9d3165f
b024a34
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 |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ type OnboardingFlowContext = { | |
| purposeSelected?: ValueOf<typeof CONST.ONBOARDING_CHOICES>; | ||
| isMergeAccountStepSkipped?: boolean; | ||
| isAccountValidated?: boolean; | ||
| hasJoinablePolicies?: boolean; | ||
| }; | ||
|
|
||
| type OnboardingStepResult = { | ||
|
|
@@ -86,7 +87,15 @@ function getDomainPrefix(context: OnboardingFlowContext): OnboardingScreen[] { | |
| return [ONBOARDING.WORK_EMAIL, ONBOARDING.WORK_EMAIL_VALIDATION]; | ||
| } | ||
| if (context.hasAccessibleDomainPolicies) { | ||
| return [ONBOARDING.PERSONAL_DETAILS, ONBOARDING.PRIVATE_DOMAIN, ONBOARDING.WORKSPACES]; | ||
| // A private-domain user reaches exactly one of PRIVATE_DOMAIN / WORKSPACES before EMPLOYEES, and only when it | ||
| // is actually shown. Unvalidated users see PRIVATE_DOMAIN and skip straight to EMPLOYEES on the magic-code | ||
| // screen. Validated users skip PRIVATE_DOMAIN and see WORKSPACES only when joinable workspaces exist; with | ||
| // none, that screen auto-skips too. Keeping a never-traversed screen in the flow makes the EMPLOYEES back | ||
| // button resolve to a blank, never-visited screen and inflates the step counter. | ||
| if (!context.isAccountValidated) { | ||
| return [ONBOARDING.PERSONAL_DETAILS, ONBOARDING.PRIVATE_DOMAIN]; | ||
| } | ||
| return context.hasJoinablePolicies ? [ONBOARDING.PERSONAL_DETAILS, ONBOARDING.WORKSPACES] : [ONBOARDING.PERSONAL_DETAILS]; | ||
|
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.
Dropping Useful? React with 👍 / 👎.
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. We already check cc: @dilshodmackbook-sketch
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. @jayeshmangwani agreed. Excluding WORKSPACES when there are no visible joinable policies is intentional — it uses the same |
||
| } | ||
| return []; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import CONST from '@src/CONST'; | ||
| import {getVisibleJoinablePoliciesCount} from '@src/libs/OnboardingUtils'; | ||
| import type {JoinablePolicies} from '@src/types/onyx'; | ||
| import type {JoinablePolicy} from '@src/types/onyx/JoinablePolicies'; | ||
|
|
||
| function createJoinablePolicy(policyID: string, policyType: JoinablePolicy['policyType']): JoinablePolicy { | ||
| return { | ||
| policyID, | ||
| policyType, | ||
| policyOwner: `${policyID}@example.com`, | ||
| policyName: `Workspace ${policyID}`, | ||
| employeeCount: 1, | ||
| hasPendingAccess: false, | ||
| automaticJoiningEnabled: false, | ||
| }; | ||
| } | ||
|
|
||
| describe('getVisibleJoinablePoliciesCount', () => { | ||
| it('returns 0 for undefined or empty joinable policies', () => { | ||
| expect(getVisibleJoinablePoliciesCount(undefined, false)).toBe(0); | ||
| expect(getVisibleJoinablePoliciesCount({}, false)).toBe(0); | ||
| }); | ||
|
|
||
| it('counts non-SUBMIT policies regardless of the SUBMIT_2026 beta', () => { | ||
| const joinablePolicies: JoinablePolicies = { | ||
| a: createJoinablePolicy('a', CONST.POLICY.TYPE.TEAM), | ||
| b: createJoinablePolicy('b', CONST.POLICY.TYPE.CORPORATE), | ||
| }; | ||
| expect(getVisibleJoinablePoliciesCount(joinablePolicies, false)).toBe(2); | ||
| expect(getVisibleJoinablePoliciesCount(joinablePolicies, true)).toBe(2); | ||
| }); | ||
|
|
||
| // Repro guard: SUBMIT policies are hidden while the beta is off, so a user whose only joinable policies are | ||
| // SUBMIT must not get a phantom WORKSPACES step (inflated counter + blank back navigation from EMPLOYEES). | ||
| it('hides SUBMIT policies when the SUBMIT_2026 beta is disabled', () => { | ||
| const joinablePolicies: JoinablePolicies = { | ||
| a: createJoinablePolicy('a', CONST.POLICY.TYPE.SUBMIT), | ||
| b: createJoinablePolicy('b', CONST.POLICY.TYPE.SUBMIT), | ||
| }; | ||
| expect(getVisibleJoinablePoliciesCount(joinablePolicies, false)).toBe(0); | ||
| }); | ||
|
|
||
| it('counts SUBMIT policies when the SUBMIT_2026 beta is enabled', () => { | ||
| const joinablePolicies: JoinablePolicies = { | ||
| a: createJoinablePolicy('a', CONST.POLICY.TYPE.SUBMIT), | ||
| b: createJoinablePolicy('b', CONST.POLICY.TYPE.SUBMIT), | ||
| }; | ||
| expect(getVisibleJoinablePoliciesCount(joinablePolicies, true)).toBe(2); | ||
| }); | ||
|
|
||
| it('counts only the visible policies in a mixed set when the beta is off', () => { | ||
| const joinablePolicies: JoinablePolicies = { | ||
| a: createJoinablePolicy('a', CONST.POLICY.TYPE.TEAM), | ||
| b: createJoinablePolicy('b', CONST.POLICY.TYPE.SUBMIT), | ||
| c: createJoinablePolicy('c', CONST.POLICY.TYPE.CORPORATE), | ||
| }; | ||
| expect(getVisibleJoinablePoliciesCount(joinablePolicies, false)).toBe(2); | ||
| expect(getVisibleJoinablePoliciesCount(joinablePolicies, true)).toBe(3); | ||
| }); | ||
| }); |
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.
This branch treats private-domain users as unvalidated unless
account.validatedis true, but the screen that sends them to the previous step usesisCurrentUserValidated(loginList, session?.email)to chooseWORKSPACESvsPRIVATE_DOMAIN(BaseOnboardingPersonalDetails). When the current login has avalidatedDatebeforeaccount.validatedis populated, a user can legitimately go Personal details → Workspaces → Employees, but the Employees back route is computed asPRIVATE_DOMAIN, recreating the never-visited/blank modal path this change is trying to avoid. The step counter/back-route context needs to use the same current-login validation signal as the navigation branch.Useful? React with 👍 / 👎.
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.
I'm trying to verify this comment to determine whether it's a legitimate bug, but I can't reproduce any issue. I'm also not sure how
validatedDatewould be set in order to test this scenario.@dilshodmackbook-sketch Are you seeing any issue when testing this flow?
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.
@jayeshmangwani you're right, I couldn't reproduce it either. This flow only runs for the signed-in primary login, and its
validatedDateandaccount.validatedreflect the same validation state, so I couldn't find a path where the two diverge before this screen renders — the back route stays in sync with navigation.If we want to be defensive about it, I can point the step-counter context at the same
isCurrentUserValidatedhelper the navigation already uses, so the two can never drift later. It's a one-line change — happy to add it if you think it's worth it, otherwise fine to leave as is.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.
Went ahead and added the defensive change we discussed — the step-counter/back-route context now derives validation from
isCurrentUserValidated(loginList, session?.email), the same signalBaseOnboardingPersonalDetailsnavigates on, instead ofaccount.validated. Even though we couldn't reproduce a divergence, this guarantees the back route and navigation can't drift apart later. It's inb024a340b76, touching only the two context builders (useOnboardingStepCounterandBaseOnboardingEmployees). Ready for another look whenever you get a chance.