Repository navigation
Description
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number:
Reproducible in staging?: Needs Reproduction (Unable to reproduce)
Reproducible in production?: Needs Reproduction
If this was caught during regression testing, add the test name, ID and link from BrowserStack:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @dominictb
Slack conversation (hyperlinked to channel name): #Expensify Bugs
Action Performed:
Precondition:
A private domain with 2 workspaces (1 workspace is also fine as long as it's not the restricted preferred workspace)
Action Performed:
- As domain Admin, go to Workspaces tab > Domains > Domain members > Add member
- Add a new member
- As member, sign up with a public email
- In What's your work email? step, fill the private domain email from step 2
- Fill validate code
Expected Result:
"Join a workspace" step is opened once
Back button should be hidden because AFAIK after merging work & public emails is one-off, you can't change the work email (this needs Product confirmation)
Actual Result:
"Join a workspace" step is opened twice. If you don't see the issue, press the Back button—you will be taken back to the first "Join a workspace" screen.
Tapping Back button on the first "Join a workspace" screen is unresponsive
Workaround:
Unknown
Platforms:
Select the officially supported platforms where the issue was reproduced:
- Android: App
- Android: mWeb Chrome
- iOS: App
- iOS: mWeb Safari
- iOS: mWeb Chrome
- Windows: Chrome
- MacOS: Chrome / Safari
Screenshots/Videos
Screen.Recording.2026-09-14.at.19.55.50.mov
Issue Owner
Current Issue Owner: @mallenexpensifyUpwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022105718225974712190
- Upwork Job ID: 2105718225974712190
- Last Price Increase: 2026-10-01
Metadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
MelvinBot commentedon Sep 14, 2026
Proposal
What is the root cause of that problem?
The
ONBOARDING_WORK_EMAILscreen stays mounted underneath the rest of the flow and pushes a second copy of the flow after the merge completes.BaseOnboardingWorkEmail.tsx:108-111is the only navigate in that effect that omits{forceReplace: true}— the other three sibling calls at L85, L89 and L92 all use it. SolinkToconverts it to aPUSH(linkTo/index.ts:236-237), leaving the work-email screen alive at the bottom of the stack.The sequence after you submit the magic code:
MergeIntoAccountAndLoginsuccessDatasetsisMergeAccountStepCompleted: true(Session/index.ts:1783) → the validation screen force-replaces itself with "Join a workspace" (Some initial fixes and code style updates #1) (BaseOnboardingWorkEmailValidation.tsx:64).OpenAppflipsaccount.validated/account.isFromPublicDomain. Both are dependencies of the still-mounted work-email effect (L114-124), so it re-runs while backgrounded.nvp_onboarding.shouldValidateis stilltrue— nothing in the success path clears it; the only code that does is the Back handler (Welcome/index.ts:94-102) — so it pushes the validation screen again, which immediately force-replaces itself with "Join a workspace" (Fix spaces #2).Final stack:
[WORK_EMAIL, WORKSPACES, WORKSPACES].The unresponsive Back is the same loop.
BaseOnboardingWorkspaces.tsx:179pops correctly toONBOARDING_WORK_EMAIL, but that flipsisFocusedback totrue, the effect re-fires,shouldValidateis still truthy, and you bounce straight forward to "Join a workspace" again. The press works; the result is invisible.Why this started recently, and why Back is visible at all
Regression source: #94486 (merged 2026-08-18), which narrowed the early-return guard at L98:
Before that change, the post-
OpenAppre-run hit this early return and took aforceReplacepath, so no duplicate entry was created. Mid-onboardinghasCompletedGuidedSetupFlowisfalse, so the guard now fails and execution falls through to the un-replacedPUSHat L109. The change itself was correct for the required-2FA handoff it was fixing — it just exposed the missingforceReplacebelow it.Why the existing back-button fix misses this path:
BaseOnboardingWorkspaces.tsx:78hides Back only whenshouldValidate === falseandbackTo === ONBOARDING_PERSONAL_DETAILS. On the merge pathshouldValidateistrueand nobackTois passed, so both halves fail. That condition came from #79031, which fixed the sibling symptom in #75978 via theOnboardingPrivateDomainroute only.Why tests didn't catch it:
tests/ui/WorkEmailOnboarding.tsxrenders one screen at a time in an isolatedStack.Navigatorand asserts on aNavigation.navigatespy, so it can never observe the work-email screen still mounted underneath or the real stack depth.Alternatives ruled out: the two
ONBOARDING_WORKSPACESpushes inBaseOnboardingPersonalDetails.tsxare user-gesture handlers, unreachable here.BaseOnboardingPrivateDomain.tsx:110already usesforceReplace, so it re-renders rather than stacking.joinablePoliciesis fetched later by the screen itself, so the "2 workspaces" precondition only affects what renders, not the duplication.Not verified: I could not confirm from code alone that the backend leaves
nvp_onboarding.shouldValidate === trueafter a successful merge, or the exactOpenAppfield deltas — both are server-side. That timing is also the likely reason staging reproduction was inconsistent. I did not reproduce this on web: the precondition needs a verified private domain plus domain-admin rights, which the test account does not have.What changes do you think we should make in order to solve the problem?
1. Fix the duplicate (and the dead Back) at the source. Add
{forceReplace: true}to the navigate atBaseOnboardingWorkEmail.tsx:109, matching its three siblings. The work-email screen then unmounts, so its effect cannot re-fire and cannot push a second copy. Back-navigation still works becauseupdateOnboardingValuesAndNavigationcallsgoBackwith an explicitONBOARDING_WORK_EMAILfallback route.2. Defensively guard the effect. L121 already lists
isFocusedas a dependency but never reads it, so a backgrounded screen can navigate. Add an earlyif (!isFocused) return;.BaseOnboardingWorkEmailValidation.tsx:69has the identical gap and should get the same guard.3. Hide the Back button on this path — needs Product confirmation. Widen
shouldHideBackButtonatBaseOnboardingWorkspaces.tsx:78to also cover the merge path (reached with nobackTo). This matches precedent on every other onboarding screen that is a flow entry point, and "Skip for now" already exists as the forward escape hatch. Any change must keep the existing test "should show the back button on join workspace for the standard personal details flow" passing — that case passes abackTo, so scoping the new condition to a missingbackTois safe.Test to add: a navigation-level test that mounts the real onboarding stack, runs the merge, and asserts the stack contains exactly one
ONBOARDING_WORKSPACESentry. The current per-screen tests structurally cannot catch this class of bug.What alternative solutions did you explore? (Optional)
Clearing
shouldValidatein theMergeIntoAccountAndLoginsuccessDatawould also stop the re-push, but it treats the symptom in the data layer and leaves the inconsistentforceReplace— any future state change that re-triggers the effect would reintroduce a duplicate.Related issues
No open duplicates found. #75978 (fixed by #79031) is the same symptom on the sibling
OnboardingPrivateDomainroute — worth reading for context, but it is a different entry path and its fix does not cover this one.💡 Suggested AI code review rule
This looks like a mechanically detectable pattern worth catching automatically. Proposed for
Expensify/App(.claude/skills/app-coding-standards):CLEAN-REACT-PATTERNS-10— Navigating effects must guard onisFocuseduseEffectwith a non-empty dependency array whose body callsNavigation.navigate/Navigation.goBackin a component that callsuseIsFocused(), when the effect body never readsisFocused. Require an earlyif (!isFocused) return;. In a stack navigator, screens below the top stay mounted, so their Onyx-driven effects keep firing and push duplicate routes onto the stack.grep -c "isFocused"returns exactly2(theuseIsFocused()declaration plus one dependency-array entry, never read in a body) and the effect body matchesNavigation\.(navigate|goBack). Running this againstsrc/surfaces both files named in this analysis.BaseOnboardingWorkEmail.tsx:114-124if (!isFocused) return;plus{forceReplace: true}at L109This does not overlap
PERF-16, which explicitly scopes itself to empty dependency arrays. If it's worth adding, a maintainer can open the rule file as a draft PR inExpensify/App.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/101119)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run · no recording available
melvin-bot commentedon Sep 14, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @abzokhattab (
External)melvin-bot commentedon Sep 14, 2026
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
abzokhattab commentedon Sep 17, 2026
@MelvinBot implement this
MelvinBot commentedon Sep 17, 2026
🤖 Draft PR created: Fix duplicate Join Workspace screen after merging a work email
Please mark it as "Ready for review" when it is ready for review.
What changed — all three items from the approved proposal:
BaseOnboardingWorkEmail.tsx:118now navigates to work email validation with{forceReplace: true}, matching its three siblings. The screen unmounts, so its effect can't re-fire and push a second "Join a workspace".if (!isFocused) return;to the navigating effects inBaseOnboardingWorkEmail.tsx:83-88andBaseOnboardingWorkEmailValidation.tsx:48-53.isFocusedwas already a dependency in both but never read.BaseOnboardingWorkspaces.tsx:80-84hides Back when this screen is the merge-flow entry point (nobackToandisMergeAccountStepCompleted). The existing personal-details condition is untouched, so that flow keeps its Back button.Two things worth your attention:
goBack()with nothing below it on the stack, which falls through toresetToAppRoot()— it would kick the user out of onboarding. If Product wants Back to stay, that needs a different destination, not just unhiding the button.Tests added and local checks run
The existing per-screen tests render one screen at a time and assert on a
Navigation.navigatespy, so they structurally cannot see a screen still mounted underneath. Three new tests cover the actual failure modes:tests/ui/WorkEmailOnboarding.tsx:438— work email screen doesn't navigate while backgroundedtests/ui/WorkEmailOnboarding.tsx:902— validation screen doesn't navigate while backgroundedtests/ui/WorkspaceOnboarding.tsx:210— Back hidden on "Join a workspace" after merging a work emailI stashed only the
src/changes and re-ran the suites: all three new tests fail without the fix, along with the two existing assertions updated forforceReplace.Passing locally:
lint-changed,typecheck,spell-changed,react-compiler-compliance-checkon the three changed source files, and 138 tests acrossWorkEmailOnboarding,WorkspaceOnboarding,PersonalDetailsOnboarding,getOnboardingStepCounterTest, andnavigateAfterOnboardingTest. The fullnpm testsuite and the Storybook smoke test were too slow for this run — CI covers both.I don't have push access to your fork, so the branch lives upstream. There are instructions on the PR for copying it to your fork if you'd rather own it there.
view run · no recording available
abzokhattab commentedon Sep 22, 2026
PR is in progress doign more tests and would open it for review
abzokhattab commentedon Sep 25, 2026
PR is still in progress
melvin-bot commentedon Sep 28, 2026
@abzokhattab this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
melvin-bot commentedon Sep 28, 2026
@abzokhattab Whoops! This issue is 2 days overdue. Let's get this updated quick!
17 remaining items
melvin-bot commentedon Oct 11, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Oct 11, 2026
Payment Summary
Resolving PRs:
Fix duplicate Join Workspace screen after merging a work email #101393
Reviewer: @abzokhattab owed $175 via NewDot
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Oct 14, 2026
Payment Summary
Contributor+: @abzokhattab due $250 via NewDot