[$250] Onboarding-Onboarding is displayed for invited to the workspace account
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: 9.5.39-2 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/tc/TC-4280 Email or phone of affected tester (no customers): N/A Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: MacBook Air 26.6.2 Chrome, iPhone 15 iOS 26.6.1 App Component: Other
Action Performed:
- Go to OldDot staging.expensify.com
- Choose the "Manage expenses for 1-9 employees" option and sign up with a new account
- Once on NewDot - don't complete the onboarding modal, close the window
- As another account invite the created account to a Collect workspace in OldDot as a member
- As the invited member, open staging.new.expensify.com Verify the onboarding modal is not displayed
Expected Result:
The onboarding modal is not displayed
Actual Result:
Onboarding is displayed for invited to the workspace as a member account
Workaround:
Unknown
Platforms:
- [ ] Android: App
- [ ] Android: mWeb Chrome
- [x] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [x] MacOS: Chrome Safari
Screenshots/Videos
https://github.com/user-attachments/assets/be5b6295-e349-4223-bfdd-f27a8544d4e2
Applause Internal Information Exported by: Nathan Lemma Bug ID: 7313593
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022121594219771749048
- Upwork Job ID: 2121594219771749048
- Last Price Increase: 2026-11-23
Issue Owner
Current Issue Owner: @sam5235
While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/ca185dd7209c6984fd5926b35616f52e67a3d85dd1b5bdf7ee5a0b23b8b5ab17
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ZhenjaHorbach (External)
Job added to Upwork: https://www.upwork.com/jobs/~022121594219771749048
Investigation Progress:
- [x] Step 1: Extract symptoms and identifiers
- [x] Step 2: Form and revise hypothesis
- [x] Step 3: Scan related issues and locate relevant code
- [x] Step 4: Gather independent researcher findings
- [x] Step 5: Evaluate the evidence
- [x] Step 6: Challenge the hypothesis against cleanup behavior and existing tests
- [ ] Step 7: Confirm the reported flow — blocked by unavailable OldDot/two-account test setup
- [x] Step 8: Prepare preliminary analysis
The evidence supports a possible saved-route restoration problem, not a confirmed root cause. Blanket dismissal would conflict with tests that intentionally preserve onboarding when a user joins a workspace during an active flow.## Issue Analysis
⚠️ Preliminary analysis — low confidence in the issue-specific root cause.
Possible cause: NewDot may restore the abandoned onboarding screen when the invited user returns, rather than start onboarding through its normal eligibility checks.
Evidence
- Membership checking already exists. Normal onboarding entry skips workspace members and invited users:
useOnboardingFlow.ts:115–144. - Startup restoration takes a different path. Navigation saves onboarding routes and can restore the last route when opening the root URL, without checking membership:
NavigationRoot.tsx:87–96,NavigationRoot.tsx:153–190.
This could explain abandon onboarding → receive invitation → reopen NewDot → see onboarding again, provided the same browser session retained the saved route.
What remains unverified
Missing or delayed membership data is an alternative explanation. To distinguish it from route restoration, capture on reopening:
- The launch URL and saved
lastVisitedPath. hasNonPersonalPolicy,introSelected.inviteType, and onboarding completion state.- Whether onboarding was restored or newly started.
Web verification was blocked, not a confirmed product failure: the tester could not establish the required OldDot signup and second-account invitation fixture. No production confirmation was obtained.
Fix assessment
No implementation-ready fix is established. Do not add another generic membership check or automatically dismiss every active onboarding flow: existing tests intentionally preserve onboarding when membership changes during an active flow (LinkOpenReportFromDeepLinkTest.ts:249–265).
Potentially related
Close onboarding after merging into an existing account also concerns onboarding remaining open after eligibility changes, but is not a confirmed duplicate.
Next Steps: Confirm the startup route and membership state before selecting a fix.
Proposal
What is the root cause of that problem?
The invited member never reaches the normal entry check; the abandoned onboarding screen is restored. NavigationRoot.tsx:94-96 saves every /onboarding... path via updateOnboardingLastVisitedPath and updateLastVisitedPath. On the next cold open (step 5: root URL, authenticated), NavigationRoot.tsx:177-186 returns getAdaptedStateFromPath(lastVisitedPath), which is the onboarding route. The only onboarding redirect in that initial-state block (NavigationRoot.tsx:155-159) fires for completed or suppressed users, never for invited members. After that, OnboardingGuard.ts:269 sets isInvitedOrGroupMember = hasNonPersonalPolicy || wasInvitedToNewDot, and OnboardingGuard.ts:312,319-321 turns that into ALLOW, so nothing pulls the user out. useOnboardingFlow.ts:116-119 also only stops starting onboarding, it never dismisses one already on screen.
What changes do you think we should make in order to solve the problem?
In the useState initializer of NavigationRoot, read hasNonPersonalPolicy (ONYXKEYS.HAS_NON_PERSONAL_POLICY) and wasInvitedToNewDotSelector(introSelected), the same inputs the guard uses, and extend the line-157 condition:
const isInvitedOrGroupMember = hasNonPersonalPolicy || wasInvitedToNewDot;
if ((isOnboardingCompleted || shouldSuppressPromotionalUI || isInvitedOrGroupMember) && shouldRedirectCompletedUser) {
return getAdaptedStateFromPath(ROUTES.HOME);
}
Also skip restoring an onboarding lastVisitedPath at line 177 for these users (fall to HOME). This does not dismiss flows that are already open, so the join-during-active-flow tests in LinkOpenReportFromDeepLinkTest.ts stay valid. isJoinWorkspaceTaskPath keeps its exemption.
Test: extend tests/unit/NavigationRootInitialStateTest.tsx. Seed lastVisitedPath = /onboarding/purpose, authenticated, onboarding not completed. Assert initial state is HOME when HAS_NON_PERSONAL_POLICY is true, or introSelected.inviteType is set. Assert it is still the onboarding route for a plain new user.
What alternative solutions did you explore? (Optional)
MelvinBot's comment names the same restoration path but proposes no fix and warns against a blanket dismissal; this change is limited to startup and gives a concrete test. I considered making OnboardingGuard redirect invited members away from onboarding, but that breaks the intentional join-during-flow behaviour.
Proposal
What is the root cause of that problem?
When a user signs up on OldDot or NewDot and reaches the onboarding flow, NavigationRoot.tsx:93-96 saves the active route into Onyx:
updateLastVisitedPath(currentPath);
if (currentPath.startsWith(`/${ROUTES.ONBOARDING_ROOT.route}`)) {
updateOnboardingLastVisitedPath(currentPath);
}
If the user abandons the tab without finishing onboarding, lastVisitedPath in Onyx remains an onboarding route (e.g. /onboarding/purpose).
When that user is later invited to a workspace as a member from OldDot, their session acquires hasNonPersonalPolicy = true (or introSelected with an invitation type). In useOnboardingFlow.ts:116-119 and OnboardingGuard.ts:269, this defines:
const isInvitedOrGroupMember = (hasNonPersonalPolicy || wasInvitedToNewDot) ?? false;
useOnboardingFlow.ts:117 correctly prevents automatically starting a new onboarding flow for invited members (if (isMigratedUser || isInvitedOrGroupMember || shouldSuppressPromotionalUI) return;).
However, on a cold launch to the root URL (step 5: https://staging.new.expensify.com/):
- In
src/libs/Navigation/NavigationRoot.tsx:153-159,initialStatecomputes:const path = initialUrl ? getPathFromURL(initialUrl) : null; const shouldRedirectCompletedUser = !!path && isOnboardingPath(path) && !isJoinWorkspaceTaskPath(path); if ((isOnboardingCompleted || shouldSuppressPromotionalUI) && shouldRedirectCompletedUser) { return getAdaptedStateFromPath(ROUTES.HOME); }- Because
initialUrlis the root URL,pathis/(not an onboarding path), soshouldRedirectCompletedUserisfalse. - Furthermore, line 157 only checks
isOnboardingCompleted || shouldSuppressPromotionalUI, omittingisInvitedOrGroupMember.
- Because
- Execution falls through to line 177:
if (shouldOpenLastVisitedPath(lastVisitedPath) && authenticated) { const isRootPath = !path || path === '' || path === '/'; const isSpecificDeepLink = path && !isRootPath; if (!isSpecificDeepLink) { return getAdaptedStateFromPath(lastVisitedPath); } }lastVisitedPath(/onboarding/purpose) is unconditionally restored viagetAdaptedStateFromPath(lastVisitedPath). - Because computing
initialStateskipsOnboardingGuard(as documented at line 156:// An initial state skips OnboardingGuard...), React Navigation mountsONBOARDING_MODAL_NAVIGATORimmediately on startup. Once mounted,OnboardingGuardallows the focused navigator and blocks navigating away, permanently trapping the invited member in the abandoned onboarding modal. - Additionally, in
src/libs/Navigation/guards/OnboardingGuard.ts:273-301, while completed users, test builds, and promotional UI suppressed sessions are actively redirected away from onboarding (REDIRECT -> ROUTES.HOME),isInvitedOrGroupMemberis only passed toshouldSkipOnboarding(returningALLOW), which fails to redirect an invited member away if an onboarding action is initiated.
What changes do you think we should make in order to solve the problem?
-
Guard
lastVisitedPathrestoration andinitialStateinsrc/libs/Navigation/NavigationRoot.tsx:- Subscribe to
HAS_NON_PERSONAL_POLICYandNVP_INTRO_SELECTEDto resolveisInvitedOrGroupMember:const [hasNonPersonalPolicy] = useOnyx(ONYXKEYS.HAS_NON_PERSONAL_POLICY); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); const isInvitedOrGroupMember = (hasNonPersonalPolicy || wasInvitedToNewDotSelector(introSelected)) ?? false; - In the
initialStatecalculator (line 157), includeisInvitedOrGroupMemberalongside completed and suppressed users so any direct launch into onboarding routes redirects toROUTES.HOME:if ((isOnboardingCompleted || shouldSuppressPromotionalUI || isInvitedOrGroupMember) && shouldRedirectCompletedUser) { return getAdaptedStateFromPath(ROUTES.HOME); } - In the
lastVisitedPathrestoration block (line 183), check iflastVisitedPathis an onboarding path (isOnboardingPath(lastVisitedPath) && !isJoinWorkspaceTaskPath(lastVisitedPath)). If the user is completed, promotional UI suppressed, or an invited/group member, do not restore the stale onboarding route; returngetAdaptedStateFromPath(ROUTES.HOME)instead:if (!isSpecificDeepLink) { if (isOnboardingPath(lastVisitedPath) && !isJoinWorkspaceTaskPath(lastVisitedPath)) { if (isOnboardingCompleted || shouldSuppressPromotionalUI || isInvitedOrGroupMember) { return getAdaptedStateFromPath(ROUTES.HOME); } } Log.info('Restoring last visited path on app startup', false, {lastVisitedPath, initialUrl, path}); return getAdaptedStateFromPath(lastVisitedPath); }
- Subscribe to
-
Redirect invited members away from onboarding in
src/libs/Navigation/guards/OnboardingGuard.ts:- In
OnboardingGuard.evaluate(after line 301), ensure any action attempting to navigate or replace into the onboarding flow redirects invited/group members toROUTES.HOME(while preservingisJoinWorkspaceTaskRoute):if (isInvitedOrGroupMember && (isNavigatingToOnboardingFlow(action) || isNavigatingWithReplace) && !isNavigatingToJoinWorkspaceTaskRoute) { Log.info('[OnboardingGuard] Redirecting invited or group member away from onboarding route to home'); return {type: 'REDIRECT', route: ROUTES.HOME}; }
- In
-
Automated Unit Tests:
- In
tests/unit/NavigationRootInitialStateTest.tsx: Add unit test asserting that an invited workspace member (ONYXKEYS.HAS_NON_PERSONAL_POLICY: true) with an uncompleted onboarding state and an onboardinglastVisitedPathresolves its initial state toROUTES.HOMEon cold start without an initial URL. - In
tests/unit/Navigation/guards/OnboardingGuard.test.ts: Add test asserting thatOnboardingGuard.evaluatereturns{type: 'REDIRECT', route: ROUTES.HOME}when an invited workspace member navigates to an onboarding route.
- In
What alternative solutions did you explore? (Optional)
- Clearing
ONBOARDING_LAST_VISITED_PATHorLAST_VISITED_PATHin Onyx when policy membership changes: Discarded becauselastVisitedPathis managed as a navigation history cursor across routes. Modifying startup state evaluation inNavigationRootand guarding against onboarding inOnboardingGuardis declarative, handles cross-tab/reconnect updates, and avoids race conditions during initial Onyx hydration. - Relying solely on
OnboardingGuard: Discarded becauseNavigationRoot'suseStatecomputes the initial state directly and passes it toNavigationContainer, which mounts the restored onboarding tree beforeOnboardingGuardevaluates navigation actions.
Contributor details
Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Proposal
Please re-state the problem that we are trying to solve in this issue.
A user signs up via OldDot, opens NewDot without finishing onboarding, and closes the app. Another account invites them as a Collect workspace member. Reopening NewDot still shows the onboarding modal instead of landing in the app.
What is the root cause of that problem?
Two mechanisms race on cold reopen after an account is invited while the client is closed:
-
Stale
lastVisitedPathrestoration bypasses onboarding eligibility checks:- During the incomplete session,
parseAndLogRoute(src/libs/Navigation/NavigationRoot.tsx:92-97) saves/onboarding/...toONYXKEYS.LAST_VISITED_PATH(line 93) andONYXKEYS.ONBOARDING_LAST_VISITED_PATH(lines 94-96). saveCurrentPathBeforeBackground(src/libs/actions/App.ts:250-260) also saves/onboarding/...toONYXKEYS.LAST_VISITED_PATH(line 259) when backgrounding on mobile.SCREENS.ONBOARDINGroutes are absent fromCONST.EXCLUDE_FROM_LAST_VISITED_PATH(src/CONST/runtimeConfigured.ts:68-82).- On reopen,
src/Expensify.tsx:313-320mountsNavigationRootbeforeAuthScreensInitHandler(src/libs/Navigation/AppNavigator/AuthScreensInitHandler.tsx:229) dispatchesApp.reconnectApp. - In
NavigationRoot(src/libs/Navigation/NavigationRoot.tsx:153-191), a root URL (/ornull) skipsshouldRedirectCompletedUser(line 155) and restoresgetAdaptedStateFromPath(lastVisitedPath)(lines 177-187) straight intoOnboardingModalNavigator. NavigationRoot(line 157) also omitsisInvitedOrGroupMember, and cached Onyx still holds stale pre-invite values at mount time.
- During the incomplete session,
-
Initial
ReconnectAppdoes not gateOnboardingGuardoruseOnboardingFlowRouter:- Because
didUserLogInDuringSession()(src/libs/SessionUtils.ts:69-95) isfalseon cold reopen,AuthScreensInitHandlercallsApp.reconnectApp(src/libs/Navigation/AppNavigator/AuthScreensInitHandler.tsx:229). reconnectApppassesisOpenApp = falsetogetOnyxDataForOpenOrReconnect(src/libs/actions/App.ts:350-356, 505), soONYXKEYS.IS_LOADING_APPstaysfalsewhileReconnectAppis in flight.OnboardingGuard.evaluate(src/libs/Navigation/guards/OnboardingGuard.ts:269, 304-357) readsGuardContext.isLoadingfromONYXKEYS.IS_LOADING_APP(src/libs/Navigation/guards/index.ts:33-39, 64). Pre-sync root actions seeisLoading = falseand staleisInvitedOrGroupMember = false, redirectingHOMEinto onboarding (OnboardingGuard.ts:339-357).useOnboardingFlowRouter(src/hooks/useOnboardingFlow.ts:84-86, 116-119, 142-146) gates only onisLoadingApp !== false || isOnboardingLoading(line 84). It can callstartOnboardingFlow(line 144) beforeReconnectAppreturnsHAS_NON_PERSONAL_POLICY = true.- Once
OnboardingModalNavigatoris mounted, receivingHAS_NON_PERSONAL_POLICY = trueleaves the modal open.OnboardingGuard(OnboardingGuard.ts:312, 319-321) returns{type: 'ALLOW'}anduseOnboardingFlowRouter(useOnboardingFlow.ts:116-119) returns early without dismissing it.
- Because
What changes do you think we should make in order to solve the problem?
-
Stop persisting and restoring non-task onboarding routes in
LAST_VISITED_PATH(src/libs/Navigation/NavigationRoot.tsx,src/libs/actions/App.ts):- In
parseAndLogRoute(src/libs/Navigation/NavigationRoot.tsx:92-97), callupdateLastVisitedPath(currentPath)only when!isOnboardingPath(currentPath) || isJoinWorkspaceTaskPath(currentPath). KeepupdateOnboardingLastVisitedPath(currentPath)(lines 94-96) unchanged. - In
saveCurrentPathBeforeBackground(src/libs/actions/App.ts:250-260), skipupdateLastVisitedPath(currentPath)(line 259) whenisOnboardingPath(currentPath) && !isJoinWorkspaceTaskPath(currentPath). - In
NavigationRoot(src/libs/Navigation/NavigationRoot.tsx:146-187), subscribe toONYXKEYS.HAS_NON_PERSONAL_POLICYandONYXKEYS.NVP_INTRO_SELECTED(viawasInvitedToNewDotSelector). AddisInvitedOrGroupMemberto theline 157redirect check. - In
NavigationRoot'sinitialStateinitializer (lines 177-187), skip restoringlastVisitedPathwhenisOnboardingPath(lastVisitedPath) && !isJoinWorkspaceTaskPath(lastVisitedPath), returninggetAdaptedStateFromPath(ROUTES.HOME)instead.
- In
-
Gate
OnboardingGuardanduseOnboardingFlowRouteron initialReconnectAppsync (src/ONYXKEYS.ts,src/libs/actions/App.ts,src/libs/Navigation/guards/,src/hooks/useOnboardingFlow.ts):- Track initial
ReconnectApppending state (for example via a newONYXKEYS.RAM_ONLY_IS_RECONNECTING_APPflag) whenAuthScreensInitHandler(src/libs/Navigation/AppNavigator/AuthScreensInitHandler.tsx:229) callsApp.reconnectApp. Clear it whenreconnectAppPromisesettles (src/libs/actions/App.ts:502-511), leavingONYXKEYS.IS_LOADING_APPuntouched. - In
src/libs/Navigation/guards/index.ts:33-39, 64andsrc/libs/Navigation/guards/OnboardingGuard.ts:304-321, treat an active online initialReconnectAppas loading insideshouldSkipOnboarding(line 308). This stops pre-sync root actions from redirectingHOMEinto onboarding (OnboardingGuard.ts:339-357). - In
useOnboardingFlowRouter(src/hooks/useOnboardingFlow.ts:84-86), return early while online initialReconnectAppis pending sostartOnboardingFlow(line 144) waits for fresh membership data. - If onboarding was auto-opened before sync (for example while offline) and
ReconnectApplands withisInvitedOrGroupMember === trueoutside aisJoinWorkspaceTaskflow, dismiss it viaNavigation.dismissModal(). Mid-flow workspace joins (tests/unit/LinkOpenReportFromDeepLinkTest.ts:249-265) remain unaffected.
- Track initial
-
Add unit tests:
- In
tests/unit/NavigationRootInitialStateTest.tsx, verify non-task onboardinglastVisitedPathvalues are not restored on root launch and invited/workspace members opening onboarding initial URLs land onROUTES.HOME. - In
tests/unit/Navigation/guards/OnboardingGuard.test.ts, verifyOnboardingGuard.evaluatereturns{type: 'ALLOW'}while initialReconnectAppis pending so pre-sync root actions do not redirect into onboarding. - Add a
useOnboardingFlowRouterunit test verifyingstartOnboardingFlowwaits for initialReconnectAppand skips onboarding whenHAS_NON_PERSONAL_POLICYreturnstrue.
- In
What alternative solutions did you explore? (Optional)
- Checking
isInvitedOrGroupMemberonly inNavigationRoot'suseStateinitializer: Rejected becauseNavigationRootmounts beforeReconnectAppfinishes, so cached Onyx still holds stale pre-invite values at mount time. - Adding
SCREENS.ONBOARDING.*toCONST.EXCLUDE_FROM_LAST_VISITED_PATH: Rejected becauseparseAndLogRoute(src/libs/Navigation/NavigationRoot.tsx:92-97) checks that list before callingupdateOnboardingLastVisitedPath(currentPath), which would break step resumption. - Setting
ONYXKEYS.IS_LOADING_APP = trueduringReconnectApp: Rejected becauseIS_LOADING_APPdrives app-wide loading skeletons and would degrade cold-reopen UX for cached sessions.
Contributor: Upwork https://www.upwork.com/freelancers/~013d295f05a578824b | Email: [email protected]
— submitted with Antigravity on the contributor's behalf
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user signs up in OldDot, opens NewDot (which enters the onboarding flow and persists /onboarding/... to Onyx), and is then invited as a member to a Collect workspace in OldDot, reopening staging.new.expensify.com still displays the NewDot onboarding flow instead of landing on the workspace/Home view.
What is the root cause of that problem?
The issue is caused by a combination of cold-start route restoration in src/libs/Navigation/NavigationRoot.tsx, missing redirect guards for users whose shouldSkipOnboarding state becomes true before completing onboarding (isInvitedOrGroupMember / isMigratedUser), and useOnboardingFlowRouter not dismissing an already-mounted ONBOARDING_MODAL_NAVIGATOR when OpenApp updates ONYXKEYS.HAS_NON_PERSONAL_POLICY or ONYXKEYS.NVP_INTRO_SELECTED asynchronously:
-
Cold-start restoration in
NavigationRoot.tsxrestores/onboarding/...fromlastVisitedPath(and direct URLs) without checkingisInvitedOrGroupMember/isMigratedUser: Insrc/libs/Navigation/NavigationRoot.tsx(lines 93–96), when the user first visits NewDot in Step 3,parseAndLogRoutesaves/onboarding/purpose(or/onboarding/work-email) intoONYXKEYS.LAST_VISITED_PATH(lastVisitedPath). When the user is subsequently invited to a workspace in OldDot (Step 4) and reopens NewDot at/(Step 5),NavigationRoot.tsx(lines 153–191) computesinitialState:- Line 155–159 only checks
if ((isOnboardingCompleted || shouldSuppressPromotionalUI) && shouldRedirectCompletedUser)onpath(initialUrl), not onlastVisitedPath, and does not includeisInvitedOrGroupMember(hasNonPersonalPolicy || wasInvitedToNewDot) orisMigratedUser(tryNewDot?.hasBeenAddedToNudgeMigration). - Line 177–187 then checks
if (shouldOpenLastVisitedPath(lastVisitedPath) && authenticated)and restoresgetAdaptedStateFromPath(lastVisitedPath)(/onboarding/...) wheneverinitialUrlis/! BecauseinitialStateis passed directly to<NavigationContainer initialState={initialState}>, it bypassesOnboardingGuard.evaluate.
- Line 155–159 only checks
-
OnboardingGuard.tsonly redirectsisOnboardingCompletedandisPromotionalUISuppressedaway from onboarding routes: Insrc/libs/Navigation/guards/OnboardingGuard.ts(lines 275–278), the guard redirectsif (onboarding && isOnboardingCompleted && isNavigatingToOnboardingFlow(action) && !isNavigatingToJoinWorkspaceTaskRoute)toROUTES.HOME. However, for an invited workspace member (isInvitedOrGroupMember = (hasNonPersonalPolicy || wasInvitedToNewDot) ?? false) or migrated user (isMigratedUser),isOnboardingCompletedis stillfalse(hasCompletedGuidedSetupFlowwas never set). As a result, lines 275–278 do not trigger, and lines 312–321 (if (shouldSkipOnboarding) { return {type: 'ALLOW'}; }) allow the navigation to/onboarding/...instead of redirecting non-join-workspace onboarding routes toROUTES.HOME. -
Asynchronous
OpenAppOnyx sync whenONBOARDING_MODAL_NAVIGATORis already mounted: When the user opens NewDot in the same browser after being invited in OldDot,ONYXKEYS.HAS_NON_PERSONAL_POLICYis initiallyfalsein local IndexedDB untilOpenAppresolves from the server. BeforeOpenAppfinishes (or fromlastVisitedPathrestoration on mount),ONBOARDING_MODAL_NAVIGATORis already mounted at the top ofRootStack. OnceOpenAppsetshasNonPersonalPolicy = true,useOnboardingFlowRouterinsrc/hooks/useOnboardingFlow.ts(lines 115–119) simply executes:const isMigratedUser = hasBeenAddedToNudgeMigration ?? false; const isInvitedOrGroupMember = (hasNonPersonalPolicy || wasInvitedToNewDot) ?? false; if (isMigratedUser || isInvitedOrGroupMember || shouldSuppressPromotionalUI) { return; }Returning early prevents
startOnboardingFlowfrom being called again, but leaves the already-mountedONBOARDING_MODAL_NAVIGATORon screen!
What changes do you think we should make in order to solve the problem?
-
src/libs/Navigation/NavigationRoot.tsx:- Read
hasNonPersonalPolicy(ONYXKEYS.HAS_NON_PERSONAL_POLICY),wasInvitedToNewDot(ONYXKEYS.NVP_INTRO_SELECTEDwithwasInvitedToNewDotSelector), andtryNewDot(ONYXKEYS.NVP_TRY_NEW_DOTwithtryNewDotOnyxSelector), and compute:const isMigratedUser = tryNewDot?.hasBeenAddedToNudgeMigration ?? false; const isInvitedOrGroupMember = (hasNonPersonalPolicy || wasInvitedToNewDot) ?? false; const shouldBypassOnboarding = isOnboardingCompleted || shouldSuppressPromotionalUI || isMigratedUser || isInvitedOrGroupMember; - In the
initialStateinitializer (lines 155–187):- Use
shouldBypassOnboardinginstead ofisOnboardingCompleted || shouldSuppressPromotionalUIwhen checkingshouldRedirectCompletedUser(!!path && isOnboardingPath(path) && !isJoinWorkspaceTaskPath(path)). - Before restoring
lastVisitedPathinif (shouldOpenLastVisitedPath(lastVisitedPath) && authenticated), check ifshouldBypassOnboarding && isOnboardingPath(lastVisitedPath) && !isJoinWorkspaceTaskPath(lastVisitedPath); if so, skip restoring the stale onboardinglastVisitedPath(or returngetAdaptedStateFromPath(ROUTES.HOME)).
- Use
- Read
-
src/libs/Navigation/guards/OnboardingGuard.ts:- In
OnboardingGuard.evaluate(lines 275–278), extend the redirect condition so invited workspace members and migrated users who have not completed guided setup are also redirected toROUTES.HOMEwhen navigating to non-join-workspace onboarding routes:if (((onboarding && isOnboardingCompleted) || isInvitedOrGroupMember || isMigratedUser) && isNavigatingToOnboardingFlow(action) && !isNavigatingToJoinWorkspaceTaskRoute) { Log.info('[OnboardingGuard] Redirecting user away from onboarding route to home'); return {type: 'REDIRECT', route: ROUTES.HOME}; }
- In
-
src/hooks/useOnboardingFlow.ts:- In
useOnboardingFlowRouter(lines 115–119), whenisMigratedUser || isInvitedOrGroupMember || shouldSuppressPromotionalUIis true, check if the root stack currently hasNAVIGATORS.ONBOARDING_MODAL_NAVIGATORfocused (and not on a join-workspace task route). If so, dismiss the onboarding modal (Navigation.dismissModal()) and clear the stale onboardinglastVisitedPathso that whenOpenAppfinishes loadinghasNonPersonalPolicy = trueafter mount, the onboarding modal is immediately closed:if (isMigratedUser || isInvitedOrGroupMember || shouldSuppressPromotionalUI) { if (Navigation.isOnboardingFlow() && !isJoinWorkspaceTaskPath(Navigation.getActiveRoute())) { Navigation.isNavigationReady().then(() => { Navigation.dismissModal(); }); } return; }
- In
What alternative solutions did you explore? (Optional)
We considered only preventing lastVisitedPath from being restored when isOnboardingPath(lastVisitedPath) is true in NavigationRoot.tsx, but that would either break legitimate onboarding step resumption for uninvited users or fail when OpenApp updates ONYXKEYS.HAS_NON_PERSONAL_POLICY asynchronously after the initial render. Handling both cold-start restoration/guarding (NavigationRoot.tsx + OnboardingGuard.ts) and reactive dismissal upon OpenApp sync (useOnboardingFlow.ts) covers both cached and fresh sessions cleanly.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~014898525b9c53fc32
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user signs up on OldDot, opens NewDot (which enters onboarding and persists an onboarding route to Onyx), closes the tab without finishing onboarding, and is then invited to a Collect workspace as a member in OldDot, reopening NewDot still mounts and displays the onboarding modal instead of bypassing onboarding and navigating directly to Home/workspace.
What is the root cause of that problem?
-
OnboardingGuardfails to redirect exempt invited members away from restored onboarding routes (src/libs/Navigation/guards/OnboardingGuard.ts:275-278vs319-321): When navigating to an onboarding route (isNavigatingToOnboardingFlow(action)istrue), line 275 only issues a redirect toROUTES.HOMEifisOnboardingCompletedistrue:if (onboarding && isOnboardingCompleted && isNavigatingToOnboardingFlow(action) && !isNavigatingToJoinWorkspaceTaskRoute) { return {type: 'REDIRECT', route: ROUTES.HOME}; }For an invited workspace member,
isOnboardingCompletedisfalse, buthasNonPersonalPolicyorwasInvitedToNewDotistrue(makingisInvitedOrGroupMember = true). Because line 275 ignoresisInvitedOrGroupMember, the guard falls through to line 319:if (shouldSkipOnboarding) { return {type: 'ALLOW'}; }Since
shouldSkipOnboardingincludesisInvitedOrGroupMember, the guard returns{type: 'ALLOW'}, authorizing the restored onboarding route to mount! -
Stale onboarding route restored from
lastVisitedPathon cold start (src/libs/Navigation/NavigationRoot.tsx:177-186&94-96): When the user initially opened NewDot,NavigationRootsaved the onboarding route tolastVisitedPathandonboardingLastVisitedPath. On cold reopen,NavigationRootreadslastVisitedPathand generates the initial navigation state targeting that saved onboarding route. BecauseOnboardingGuardreturnsALLOW, the app mounts the abandoned onboarding screen.
What changes do you think we should make in order to solve the problem?
-
Update
OnboardingGuard.ts:275-278to redirect all exempt/skip-onboarding users away from onboarding routes: Update the redirect check to evaluate whether the user should skip onboarding (e.g.isInvitedOrGroupMember,isMigratedUser, orisOnboardingCompleted):const isExemptFromOnboarding = isOnboardingCompleted || isInvitedOrGroupMember || isMigratedUser; if (isExemptFromOnboarding && isNavigatingToOnboardingFlow(action) && !isNavigatingToJoinWorkspaceTaskRoute) { Log.info('[OnboardingGuard] Redirecting exempt/completed user away from onboarding route to home'); return {type: 'REDIRECT', route: ROUTES.HOME}; }This guarantees that even if a stale onboarding route is restored from cache or accessed via deep link,
OnboardingGuardintercepts it and redirects the invited member directly toROUTES.HOME. -
Clean up stale onboarding paths when non-personal policies are detected: When
ONYXKEYS.HAS_NON_PERSONAL_POLICYorwasInvitedToNewDotevaluates totrue, clear or overwriteONYXKEYS.ONBOARDING_LAST_VISITED_PATHand resetlastVisitedPathif it points to an onboarding subroute, preventing unnecessary redirect thrashing on initial load. -
Automated tests:
- In
tests/unit/OnboardingGuardTest.ts: Add test cases verifying that whenhasNonPersonalPolicy: trueorwasInvitedToNewDot: true(withisOnboardingCompleted: false), navigating to any onboarding route (/onboarding/purpose,/onboarding/workspaces, etc.) returns{type: 'REDIRECT', route: ROUTES.HOME}. - In
tests/unit/NavigationRootTest.tsx: Test that a cold open with a stale onboardinglastVisitedPathfor an invited workspace member lands onROUTES.HOME.
- In
What alternative solutions did you explore? (Optional)
- Only clearing
lastVisitedPathinNavigationRoot: Rejected because if an invited member clicks a stale browser bookmark or external deeplink to/onboarding/...,OnboardingGuardwould still returnALLOWand display onboarding. Fixing the guard at the navigation boundary protects both cold starts and direct link navigation.
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user signs up in OldDot, opens NewDot without finishing onboarding, closes the window, is invited as a member to a Collect workspace in OldDot, and then reopens NewDot (staging.new.expensify.com), the onboarding modal is still displayed instead of landing directly in the app.
What is the root cause of that problem?
Two gaps combine when an account with an unfinished onboarding session is invited to a workspace while NewDot is closed:
-
Startup
initialStaterestores saved onboarding routes without checking workspace-member or invitation exemptions:- In Step 3,
parseAndLogRoute(src/libs/Navigation/NavigationRoot.tsx:92-96) saves the active/onboarding/...path toONYXKEYS.LAST_VISITED_PATHandONYXKEYS.ONBOARDING_LAST_VISITED_PATH. - On Step 5 reopen at
/,NavigationRoot(src/libs/Navigation/NavigationRoot.tsx:153-187) only checksisOnboardingCompleted || shouldSuppressPromotionalUIagainstinitialUrl(lines 155-159), omittingisInvitedOrGroupMember(hasNonPersonalPolicy || wasInvitedToNewDot) andisMigratedUser, and then restoresgetAdaptedStateFromPath(lastVisitedPath)(lines 177-186). BecauseinitialStategoes straight toNavigationContainer, it bypassesOnboardingGuardand mountsONBOARDING_MODAL_NAVIGATORimmediately.
- In Step 3,
-
Initial
ReconnectAppsync updates membership asynchronously without dismissing the startup-restored onboarding modal:- Because the workspace invitation in Step 4 occurred while NewDot was closed, cached IndexedDB still holds
HAS_NON_PERSONAL_POLICYasfalse/undefinedwhenNavigationRootmounts (beforeAuthScreensInitHandler.tsx:229dispatchesApp.reconnectApp, which setsONYXKEYS.IS_LOADING_REPORT_DATAtotrueuntil sync finishes rather thanONYXKEYS.IS_LOADING_APP). - Once
ReconnectAppresolves and setsONYXKEYS.HAS_NON_PERSONAL_POLICYtotrue,useOnboardingFlowRouter(src/hooks/useOnboardingFlow.ts:115-119) seesisInvitedOrGroupMember === trueand returns early. That early return only avoids starting a new flow—it leaves the startup-mountedONBOARDING_MODAL_NAVIGATORstuck on screen.
- Because the workspace invitation in Step 4 occurred while NewDot was closed, cached IndexedDB still holds
What changes do you think we should make in order to solve the problem?
-
Prevent
NavigationRootfrom restoring or opening non-task onboarding routes for exempt users (src/libs/Navigation/NavigationRoot.tsx):- Read
ONYXKEYS.HAS_NON_PERSONAL_POLICY,ONYXKEYS.NVP_INTRO_SELECTED(wasInvitedToNewDotSelector), andONYXKEYS.NVP_TRY_NEW_DOT(tryNewDotOnyxSelector) inNavigationRootto computeisInvitedOrGroupMemberandisMigratedUseralongsideisOnboardingCompletedandshouldSuppressPromotionalUI. - In the
initialStateinitializer (lines 155-187), returngetAdaptedStateFromPath(ROUTES.HOME)both wheninitialUrlis a non-task onboarding path and whenlastVisitedPathis a non-task onboarding path (isOnboardingPath(lastVisitedPath) && !isJoinWorkspaceTaskPath(lastVisitedPath)) for these exempt users.
- Read
-
Wait for initial
ReconnectAppreport/policy sync and dismiss only startup-restored onboarding modals inuseOnboardingFlowRouter(src/hooks/useOnboardingFlow.ts):- Read
ONYXKEYS.IS_LOADING_REPORT_DATAanduseNetwork().isOffline, and track ahasEvaluatedStartupSyncRefref so startup exemption is evaluated once initial sync settles (!isOffline && isLoadingReportDatawaits for the in-flightOpenApp/ReconnectAppstarted inAuthScreensInitHandler.tsx:226-229before auto-starting or dismissing onboarding). - On that initial post-sync check, if
isMigratedUser || isInvitedOrGroupMember || shouldSuppressPromotionalUIistrueandNavigation.isOnboardingFlow()is mounted on a non-task route (!isJoinWorkspaceTaskPath(Navigation.getActiveRoute())), clearONYXKEYS.ONBOARDING_LAST_VISITED_PATHviaupdateOnboardingLastVisitedPath('')and callNavigation.isNavigationReady().then(() => Navigation.dismissModal())to revealTAB_NAVIGATOR(HOME) underneath (which also updatesLAST_VISITED_PATHto/). - Because this dismissal runs only on the initial startup sync check (
hasEvaluatedStartupSyncRef), any workspace join or account merge performed later during an active onboarding session (BaseOnboardingWorkspaces,BaseOnboardingWorkEmailValidation, andLinkOpenReportFromDeepLinkTest.ts:249-265) keeps onboarding open untilcompleteOnboardingfinishes.
- Read
-
Redirect external warm deep links into onboarding for exempt users in
OnboardingGuard(src/libs/Navigation/guards/OnboardingGuard.ts):- When
ONBOARDING_MODAL_NAVIGATORis not already focused (!isOnboardingFocused) andisInvitedOrGroupMember || isMigratedUseristrue, return{type: 'REDIRECT', route: ROUTES.HOME}forisNavigatingToOnboardingFlow(action) && !isNavigatingToJoinWorkspaceTaskRoute. Scoping this to!isOnboardingFocusedblocks warm/onboarding/...links without interfering with internal step transitions (such asONBOARDING_WORKSPACEStoONBOARDING_PERSONAL_DETAILS) inside an active flow.
- When
-
Unit tests:
- Extend
tests/unit/NavigationRootInitialStateTest.tsxto verify that invited/workspace members (HAS_NON_PERSONAL_POLICY: trueorNVP_INTRO_SELECTED.inviteType) with incomplete onboarding land onROUTES.HOMEwhenlastVisitedPathorinitialUrlis/onboarding/purpose, while plain uninvited users still restore their saved onboarding step. - Add unit tests in
tests/unit/Navigation/guards/OnboardingGuard.test.tsand foruseOnboardingFlowRoutercovering post-ReconnectAppstartup dismissal vs. preserving an active mid-session workspace join.
- Extend
What alternative solutions did you explore? (Optional)
- Checking
isInvitedOrGroupMemberonly inNavigationRoot'suseStateinitializer: Insufficient on its own because Step 4 invites the user while NewDot is closed, so cached Onyx still holds pre-invite state untilReconnectAppresolves after mount. - Unconditionally redirecting
isInvitedOrGroupMemberinOnboardingGuardor dismissing onboarding on everyHAS_NON_PERSONAL_POLICYchange: Breaks in-session workspace joins (BaseOnboardingWorkspaces.tsx:169-174, 211) and account merges (BaseOnboardingWorkEmailValidation.tsx:134-143) whereHAS_NON_PERSONAL_POLICYbecomestruebeforeONBOARDING_PERSONAL_DETAILS/completeOnboardingruns. - Stopping
parseAndLogRoutefrom saving/onboarding/...toLAST_VISITED_PATH: Degrades cold-start step resumption for normal uninvited users by mountingHOMEfirst beforeuseOnboardingFlowRouterresets back into onboarding.
📣 @chaos666888! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
- Make sure you've read and understood the contributing guidelines.
- Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
- Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user signs up on OldDot (Manage expenses for 1-9 employees), opens NewDot without finishing the onboarding modal (so an /onboarding/... path is saved in lastVisitedPath), and is then invited as a member to a Collect workspace in OldDot, reopening NewDot (staging.new.expensify.com) still displays the onboarding modal instead of taking the invited member to Home.
What is the root cause of that problem?
- Cold-start
initialStateandlastVisitedPathrestoration insrc/libs/Navigation/NavigationRoot.tsxbypassesisInvitedOrGroupMember:- While
useOnboardingFlow.tsandOnboardingGuard.tsdefineisInvitedOrGroupMember = hasNonPersonalPolicy || wasInvitedToNewDotSelector(introSelected)to skip onboarding for workspace members,NavigationRoot.tsx(lines 153-190) only checksisOnboardingCompleted || shouldSuppressPromotionalUIwhen computinginitialState. - When the returning user opens NewDot at the root URL (
/),NavigationRootrestoreslastVisitedPath(/onboarding/...) directly viagetAdaptedStateFromPath(lastVisitedPath). Because computinginitialStatebypassesOnboardingGuard,ONBOARDING_MODAL_NAVIGATORmounts directly on startup.
- While
OnboardingGuard.tsdoes not actively redirectisInvitedOrGroupMemberaway from onboarding routes (src/libs/Navigation/guards/OnboardingGuard.ts:273-301):- In
OnboardingGuard.evaluate,isInvitedOrGroupMemberis included inshouldSkipOnboarding(which returns{type: 'ALLOW'}), but is omitted from the active redirect check (if ((isOnboardingCompleted || isSingleNewDotEntry || isTestBuild || shouldSuppressPromotionalUI) && ...) return {type: 'REDIRECT', route: ROUTES.HOME}). Thus, when an invited workspace member's navigation state targets an onboarding route (or whenhasNonPersonalPolicyhydrates via Onyx),OnboardingGuardallows them to remain on the onboarding modal instead of redirecting toROUTES.HOME.
- In
What changes do you think we should make in order to solve the problem?
- Include
isInvitedOrGroupMemberinNavigationRoot.tsxstartup route resolution (src/libs/Navigation/NavigationRoot.tsx):- Subscribe to
ONYXKEYS.HAS_NON_PERSONAL_POLICYandONYXKEYS.NVP_INTRO_SELECTED(usingwasInvitedToNewDotSelector) to computeisInvitedOrGroupMember. - In the
initialStatecalculation (line 157) and thelastVisitedPathonboarding restoration guard (line 183), treatisInvitedOrGroupMemberalongsideisOnboardingCompleted || shouldSuppressPromotionalUIso stale onboardinglastVisitedPathentries resolve togetAdaptedStateFromPath(ROUTES.HOME)(unless navigating to a join-workspace task route).
- Subscribe to
- Redirect
isInvitedOrGroupMemberaway from onboarding routes insrc/libs/Navigation/guards/OnboardingGuard.ts:- In
OnboardingGuard.evaluate(lines 285-301), includeisInvitedOrGroupMemberin the redirect condition so any navigation/replace into onboarding routes (other than join-workspace task routes) returns{type: 'REDIRECT', route: ROUTES.HOME}. - Dismiss the mounted onboarding modal if
hasNonPersonalPolicyhydrates after initial mount while the user is on an onboarding route.
- In
- Add unit tests:
- Add unit tests in
tests/unit/NavigationRootInitialStateTest.tsxandtests/unit/Navigation/guards/OnboardingGuard.test.tsverifying that an invited member (HAS_NON_PERSONAL_POLICY: true) with an uncompleted onboarding state and an/onboarding/...lastVisitedPathlands onROUTES.HOME.
- Add unit tests in
What alternative solutions did you explore? (Optional)
- Clearing
LAST_VISITED_PATHin Onyx when policy data changes: Rejected because handlingisInvitedOrGroupMemberdeclaratively inNavigationRootandOnboardingGuardmatches howisOnboardingCompletedandshouldSuppressPromotionalUIare already handled without mutating persisted route history.
When a user signs up on OldDot ( There are three compounding causes that keep the invited workspace member trapped in onboarding: Unconditional Missing redirect for No dismissal when Guard Redirect invited members away from onboarding in Dismiss mounted onboarding modal on hydration in Add automated tests:Proposal
Proposal
Please re-state the problem that we are trying to solve in this issue.
Manage expenses for 1-9 employees), opens NewDot without completing the onboarding modal (which saves an /onboarding/... route to lastVisitedPath), closes the window, is invited as a member to a Collect workspace in OldDot, and then reopens NewDot at staging.new.expensify.com, the onboarding modal is still displayed instead of landing in the app at Home.What is the root cause of that problem?
lastVisitedPath restoration of onboarding routes in src/libs/Navigation/NavigationRoot.tsx:
parseAndLogRoute saves the active onboarding path (/onboarding/...) to ONYXKEYS.LAST_VISITED_PATH and ONYXKEYS.ONBOARDING_LAST_VISITED_PATH.https://staging.new.expensify.com/), initialUrl is the root URL (/).NavigationRoot.tsx:155-159, shouldRedirectCompletedUser is false (because path is /, not an onboarding URL), and the redirect condition only checks isOnboardingCompleted, completely omitting isInvitedOrGroupMember.if (shouldOpenLastVisitedPath(lastVisitedPath) && authenticated) {
if (!isSpecificDeepLink) {
return getAdaptedStateFromPath(lastVisitedPath);
}
}
lastVisitedPath (/onboarding/purpose) is unconditionally restored into initialState via getAdaptedStateFromPath(lastVisitedPath) without verifying whether lastVisitedPath is an onboarding route or whether the user is eligible for onboarding.initialState skips navigation guards, React Navigation immediately mounts ONBOARDING_MODAL_NAVIGATOR on startup.isInvitedOrGroupMember in src/libs/Navigation/guards/OnboardingGuard.ts:
OnboardingGuard.evaluate:
Completed users are actively redirected to if (isOnboardingCompleted && isNavigatingToOnboardingFlow(action) && !isNavigatingToJoinWorkspaceTaskRoute) {
return {type: 'REDIRECT', route: ROUTES.HOME};
}
ROUTES.HOME. However, isInvitedOrGroupMember is omitted from this redirect check. Instead, isInvitedOrGroupMember is only included in shouldSkipOnboarding (lines 280–298), which returns {type: 'ALLOW'}. Once mounted, OnboardingGuard allows the user to remain on the onboarding screen rather than redirecting them to ROUTES.HOME.HAS_NON_PERSONAL_POLICY hydrates asynchronously in src/hooks/useOnboardingFlow.ts:
ReconnectApp / OpenApp returns from the backend.ReconnectApp resolves and hasNonPersonalPolicy becomes true, useOnboardingFlow.ts:110 merely returns early (if (isInvitedOrGroupMember) return;), which prevents starting onboarding but never dismisses the onboarding modal that was already mounted by initialState.What changes do you think we should make in order to solve the problem?
lastVisitedPath restoration and initialState in src/libs/Navigation/NavigationRoot.tsx:
ONYXKEYS.HAS_NON_PERSONAL_POLICY and ONYXKEYS.NVP_INTRO_SELECTED:
const [hasNonPersonalPolicy] = useOnyx(ONYXKEYS.HAS_NON_PERSONAL_POLICY);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const isInvitedOrGroupMember = (hasNonPersonalPolicy || wasInvitedToNewDotSelector(introSelected)) ?? false;
initialState (line 157), include isInvitedOrGroupMember:
const shouldRedirectOnboardingUser = !!path && isOnboardingPath(path) && !isJoinWorkspaceTaskPath(path);
if ((isOnboardingCompleted || shouldSuppressPromotionalUI || isInvitedOrGroupMember) && shouldRedirectOnboardingUser) {
return getAdaptedStateFromPath(ROUTES.HOME);
}
lastVisitedPath restoration check (line 177), check if lastVisitedPath is an onboarding route. If isOnboardingPath(lastVisitedPath) && !isJoinWorkspaceTaskPath(lastVisitedPath) and isOnboardingCompleted || shouldSuppressPromotionalUI || isInvitedOrGroupMember, do not restore the stale onboarding path; resolve to ROUTES.HOME instead:
if (shouldOpenLastVisitedPath(lastVisitedPath) && authenticated) {
const isRootPath = !path || path === '' || path === '/';
const isSpecificDeepLink = path && !isRootPath;
if (!isSpecificDeepLink) {
if (isOnboardingPath(lastVisitedPath) && !isJoinWorkspaceTaskPath(lastVisitedPath)) {
if (isOnboardingCompleted || shouldSuppressPromotionalUI || isInvitedOrGroupMember) {
return getAdaptedStateFromPath(ROUTES.HOME);
}
}
Log.info('Restoring last visited path on app startup', false, {lastVisitedPath, initialUrl, path});
return getAdaptedStateFromPath(lastVisitedPath);
}
}
src/libs/Navigation/guards/OnboardingGuard.ts:
isInvitedOrGroupMember:
if ((isOnboardingCompleted || isInvitedOrGroupMember) && isNavigatingToOnboardingFlow(action) && !isNavigatingToJoinWorkspaceTaskRoute) {
Log.info('[OnboardingGuard] Redirecting invited or completed user away from onboarding route to home');
return {type: 'REDIRECT', route: ROUTES.HOME};
}
src/hooks/useOnboardingFlow.ts:
isInvitedOrGroupMember becomes true after ReconnectApp hydrates Onyx:
if (isMigratedUser || isInvitedOrGroupMember || shouldSuppressPromotionalUI) {
if (isInvitedOrGroupMember) {
const activeRoute = Navigation.getActiveRoute();
if (isOnboardingPath(activeRoute) && !isJoinWorkspaceTaskPath(activeRoute)) {
Navigation.navigate(ROUTES.HOME);
}
}
return;
}
ReconnectApp returns policy membership, the modal dismisses automatically as soon as the invite data arrives.
tests/unit/NavigationRootInitialStateTest.tsx:
HAS_NON_PERSONAL_POLICY: true) with an incomplete onboarding state and an /onboarding/... lastVisitedPath resolves its initial state to ROUTES.HOME on root URL cold start.tests/unit/Navigation/guards/OnboardingGuard.test.ts:
OnboardingGuard returns {type: 'REDIRECT', route: ROUTES.HOME} when an invited workspace member attempts to navigate to an onboarding route (non-join-task).What alternative solutions did you explore? (Optional)
LAST_VISITED_PATH or ONBOARDING_LAST_VISITED_PATH in Onyx when policy data changes: Discarded because LAST_VISITED_PATH is a navigation history cursor; mutating stored route history during background policy synchronization introduces race conditions across tabs and sessions.NavigationRoot.tsx: Discarded because when the invite is sent while NewDot is closed, cached client storage lacks the new workspace until ReconnectApp completes over the network; combining NavigationRoot, OnboardingGuard, and useOnboardingFlow ensures instant and seamless dismissal across both cached and freshly hydrated states.Test Plan
staging.new.expensify.com:
/).staging.new.expensify.com/onboarding/purpose) in the browser address bar:
/).
staging.new.expensify.com.
Contributor details
Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0105126232377c4c5c
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Contributor details:
- Expensify account email: [email protected]
- Upwork profile: https://www.upwork.com/freelancers/~013b564a690d9bcdab
Proposal
Problem
A user signs up via OldDot, opens NewDot without finishing onboarding, and closes the
window. The user is then invited to a Collect workspace as a member. On reopening
staging.new.expensify.com, the onboarding modal is shown instead of the app. An invited
workspace member should land in the app (Home), with no onboarding modal.
Root cause - and why the fix has to be in three places
NavigationRoot.tsx saves every /onboarding/... path to lastVisitedPath and, on a
cold open at the root URL, restores it with no exemption check. OnboardingGuard.ts then
turns the invited-member status into ALLOW, and useOnboardingFlow.ts only stops
STARTING onboarding - nothing dismisses one already on screen.
There is one timing fact that decides where the fix can live, and it is easy to miss:
HAS_NON_PERSONAL_POLICY is false in local storage until OpenApp / ReconnectApp
resolves from the server, and NavigationRoot mounts BEFORE that sync
(Expensify.tsx waits only for the initial URL, not for the policy sync).
setUpPoliciesAndNavigate only navigates when the URL carries an exitTo param, so in
this repro no navigation action is dispatched after the policy sync. Consequences:
- An
initialStatefix alone only works when the flag is already persisted (a second launch). It does NOT fix the repro as written: the flag arrives after mount, and theuseStateinitializer never re-runs. - A guard fix alone cannot work either:
OnboardingGuardonly evaluates dispatched navigation actions, and the repro dispatches none after mount. - The repro can only be fixed by a post-mount reaction when the exemption hydrates - and
that reaction must be scoped to startup, because
useOnboardingFlowRouter's effect re-runs when the invite flag changes. An unscoped dismissal would also fire when a user joins a workspace MID-FLOW during active onboarding, which is intentional behaviour protected byLinkOpenReportFromDeepLinkTest("does not bypass an open onboarding flow for an invited user", "keeps an open onboarding flow in charge even after the user joins a workspace").
Changes
-
src/libs/Navigation/NavigationRoot.tsx- initial state (covers flags already persisted). Subscribe toHAS_NON_PERSONAL_POLICYandNVP_INTRO_SELECTED(wasInvitedToNewDot), plustryNewDotfor migration, and computeisInvitedOrGroupMember = hasNonPersonalPolicy || wasInvitedToNewDotandshouldBypassOnboarding = isOnboardingCompleted || shouldSuppressPromotionalUI || isMigratedUser || isInvitedOrGroupMember. Use it in both places: the redirect for a direct launch into an onboarding URL, and thelastVisitedPathrestoration branch - when the user is exempt and the stored path is an onboarding route (and not a join-workspace-task route), restoreROUTES.HOMEinstead. TheisJoinWorkspaceTaskPathexemption and the migrated-user-welcome branch are untouched. -
src/libs/Navigation/guards/OnboardingGuard.ts- deep-link defence. Extend the redirect so exempt users are also redirected to HOME when an action targets a non-task onboarding route. Stated honestly: this does not fix the repro on its own (the guard only evaluates dispatched actions), it protects deep links and programmatic navigations into onboarding. -
src/hooks/useOnboardingFlow.ts- one-shot startup dismissal (the missing piece). InuseOnboardingFlowRouter, add ahasEvaluatedStartupDismissalRefthat is set onceisLoadingAppbecomes false - the first moment the policy flag is trustworthy after the initial sync. If, at that moment, the user is exempt (isMigratedUser || isInvitedOrGroupMember || shouldSuppressPromotionalUI), the focused route is an onboarding route, and it is not a join-workspace-task route, dismiss the modal withNavigation.dismissModal()and clearONBOARDING_LAST_VISITED_PATH:Navigation.isNavigationReady().then(() => { Navigation.dismissModal(); updateOnboardingLastVisitedPath(''); }).- Gated on
isLoadingApp, not on report-data loading: the policy flag arrives with the initialOpenApp/ReconnectAppload, which is whatisLoadingApptracks. - One-shot by design: the decision is made once, at startup. A user who gets invited
mid-flow - after the ref is spent - keeps their onboarding, exactly as the
LinkOpenReportFromDeepLinkTestcases require. dismissModal()(dispatchesDISMISS_MODAL), notNavigation.navigate(ROUTES.HOME): the guard'sACTIONS_THAT_CAN_LEAVE_ONBOARDINGareNAVIGATE/PUSH/REPLACE/POP_TO, andshouldPreventResetcoversRESET/GO_BACK-DISMISS_MODALis in neither set, so the guard cannot block it, and it deterministically removes the mounted modal to revealTAB_NAVIGATOR(HOME). Whether a NAVIGATE from inside the modal navigator actually dismisses the mounted modal is uncertain.- The stale
ONBOARDING_LAST_VISITED_PATHis cleared so the step is not offered as a resume point later;LAST_VISITED_PATHself-heals on the next navigation, and the next cold start is covered by step 1 since the flag is persisted by then.
- Gated on
Not changed: persisting onboarding routes in parseAndLogRoute (changing that would
alter resume behaviour for ALL users and is not needed once steps 1 and 3 exist); no new
Onyx key is added (isLoadingApp is the existing signal); the join-workspace-task
routes, the 2FA-setup flow and hybrid-app single-entry flows are untouched; the existing
early return in useOnboardingFlowRouter (which only stops STARTING onboarding) is kept.
Tests
tests/unit/NavigationRootInitialStateTest.tsx: invited member (HAS_NON_PERSONAL_POLICY: true), onboarding incomplete,lastVisitedPath = /onboarding/purpose, root URL, authenticated - initial state is HOME. Same withintroSelected.inviteTypeset. Control: a plain new user still restores the onboarding route.tests/unit/Navigation/guards/OnboardingGuard.test.ts: an invited member navigating to/onboarding/purpose(non-task) is redirected to HOME; a join-workspace-task route is not redirected.tests/unit/LinkOpenReportFromDeepLinkTest.ts: no change - must keep passing; the two cases ("does not bypass an open onboarding flow for an invited user", "keeps an open onboarding flow in charge even after the user joins a workspace") are the guard rails for the one-shot scoping in step 3.- If a harness exists for
useOnboardingFlowRouter: the startup dismissal fires once when the flag flips post-mount, and does NOT fire when the flag flips mid-flow after the startup evaluation. Otherwise this is covered by the NavigationRoot + guard tests plus manual QA of the exact repro steps.
Alternatives considered
- Initial state only. Rejected: it does not fix the repro as written, because the
policy flag is not yet true when
NavigationRootmounts. - Guard only. Rejected: the guard never evaluates in the repro flow, because no navigation action is dispatched after the policy sync.
- Unscoped dismissal when the flag flips. Rejected: it would dismiss onboarding
mid-flow when a user joins a workspace during active onboarding, breaking the
intentional behaviour in
LinkOpenReportFromDeepLinkTest. - Stop persisting onboarding routes in
LAST_VISITED_PATH. Rejected: it changes resume behaviour for every user and is unnecessary once the initial-state fix and the one-shot dismissal exist. - Wait for report-data loading before deciding. Rejected: the policy flag arrives
with the initial app load (
isLoadingApp); report-data loading is irrelevant here and adds a failure mode if it never settles as expected.
📣 @dankezo! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
- Make sure you've read and understood the contributing guidelines.
- Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
- Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~013b564a690d9bcdab
✅ Contributor details stored successfully. Thank you for contributing to Expensify!