Repository navigation
Description
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: v9.3.68-1
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/projects/2219752/folder/13176924/test-cases/41237586
Email or phone of affected tester (no customers): lattelover1412+070518@gmail.com
Issue reported by: Applause Internal Team
Bug source: Regression TC Execution
Device used: Chrome, android
App Component: Other
Action Performed:
Precondition:
Login to OD as a expensifail account A
Create a workspace
Add expensifail account B as a member
- Launch app
- User logged in with brand new account (gmail)
- When "What’s your work email?" modal display >> enter expensifail account B from the precondition
- Tap "Add Work Email" button
Expected Result:
Step 5: a "Verify your work email" modal displayed with a field to enter magic code should be displayed, the magic code received and user is able complete the onboarding flow
Actual Result:
A page show "Could not add work email" displayed instead "Verify your work email" modal displayed with a field to enter magic code
Workaround:
Unknown
Platforms:
- Android: App
- Android: mWeb Chrome
- iOS: App
- iOS: mWeb Safari
- iOS: mWeb Chrome
- Windows: Chrome
- MacOS: Chrome / Safari
Screenshots/Videos
Video.mp4
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022052300928016840812
- Upwork Job ID: 2052300928016840812
- Last Price Increase: 2026-05-14
Issue Owner
Current Issue Owner: @carlosmiceliMetadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
MelvinBot commentedon May 7, 2026
Proposal
What is the root cause of that problem?
The backend
AddWorkEmailcommand is returning a non-200 response when the submitted work email belongs to an existing account that is already a workspace member. On the client side,AddWorkEmail()definesfailureDatathat unconditionally setsisMergingAccountBlocked: trueon any backend failure. This causesBaseOnboardingWorkEmailto render theOnboardingMergingAccountBlockedView("Couldn't add work email") instead of navigating to the magic code verification screen.The success path relies entirely on the server returning OnyxUpdates with
shouldValidate: trueonNVP_ONBOARDING-- the clientsuccessDataonly clears the loading state. So when the backend errors out for this scenario,shouldValidateis never set and the useEffect that would navigate to the verification screen never triggers.What changes do you think we should make in order to solve the problem?
This is likely a backend issue in the
AddWorkEmailcommand handler. The backend should return a successful response withshouldValidate: truefor the case where the work email belongs to an existing account/workspace member, so the user gets the magic code verification flow instead of an error.If the backend fix is confirmed, no client-side changes are needed -- the existing client logic already correctly handles
shouldValidate: trueby navigating to the verification screen.If there's a legitimate backend reason to reject this case, the client-side
failureDatainAddWorkEmail()could be made more granular by checking the server error response and providing a more helpful error message instead of the generic "Couldn't add work email" block.What alternative solutions did you explore? (Optional)
I investigated a potential client-side race condition:
updateOnboardingValuesAndNavigationusesOnyx.set(full replacement) withshouldValidate: undefined, which could theoretically wipe server-set values. However, this function is only called on back-button press from the validation screen, not during the initialAddWorkEmailflow, so it's unlikely to be the primary cause of this bug.Investigation details
Flow traced:
BaseOnboardingWorkEmailand taps "Add Work Email"submitWorkEmailcallsAddWorkEmail(email)which sendsAPI.write('ADD_WORK_EMAIL', {workEmail})shouldValidate: trueonNVP_ONBOARDING->useEffectnavigates toONBOARDING_WORK_EMAIL_VALIDATIONroute -> user sees magic code screenfailureDatasetsisMergingAccountBlocked: true->BaseOnboardingWorkEmailrendersOnboardingMergingAccountBlockedView-> user sees "Couldn't add work email"Key code locations:
AddWorkEmailfunctionshouldValidateisMergingAccountBlockedcheck showing error viewOnboardingMergingAccountBlockedViewcomponentNext Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.David-2002065 commentedon May 7, 2026
Proposal
What is the root cause of that problem?
I tracked the regression to the
AddWorkEmailaction insrc/libs/actions/Session/index.ts. ItsfailureDataunconditionally writesisMergingAccountBlocked: truetoNVP_ONBOARDINGfor any API failure:https://github.com/Expensify/App/blob/main/src/libs/actions/Session/index.ts#L1481-L1496
The "What's your work email?" screen then renders
OnboardingMergingAccountBlockedView(whose title is"Couldn't add work email") whenever that flag is true:https://github.com/Expensify/App/blob/main/src/pages/OnboardingWorkEmail/BaseOnboardingWorkEmail.tsx#L162-L168
When the user enters an existing workspace member's email, the backend returns a non-success
jsonCodeso the user can be sent through the magic-code merge flow. The backend response carries theshouldValidate: trueonyxData update that should navigate the user toROUTES.ONBOARDING_WORK_EMAIL_VALIDATION(the "Verify your work email" modal — see the navigation effect at https://github.com/Expensify/App/blob/main/src/pages/OnboardingWorkEmail/BaseOnboardingWorkEmail.tsx#L71-L99). But because our localfailureDataruns on every non-success response and force-setsisMergingAccountBlocked: true, the block view wins the JSX condition and hides the verification flow entirely.This was introduced by
67adc770546— "show blocking screen for all failures ofaddWorkEmail" on July 4, 2025. Prior to that commit, the screen only blocked whenonboardingErrorMessage === ONBOARDING_2FA_REQUIRED_ERROR_MESSAGE, leaving the verify-email merge path untouched.What changes do you think we should make in order to solve the problem?
I'd switch
AddWorkEmailtoAPI.makeRequestWithSideEffectsso we can inspect the backend response and only setisMergingAccountBlockedfor genuinely non-recoverable errors (e.g. the 2FA case). For everything else we let the backend-driven onyxData (shouldValidate, error message, etc.) drive the UI, which restores the merge/verify path:And replace the fire-and-forget
API.writewith a side-effect call that decides what to do based on the response (mirroring the pattern already used byMergeIntoAccountAndLoginat https://github.com/Expensify/App/blob/main/src/libs/actions/Session/index.ts#L1569-L1577):Supporting changes:
ONBOARDING_2FA_REQUIRED_ERROR_MESSAGE(or whichever specific blocking-error sentinels the backend uses) toCONST.ERROR— it was deleted alongside the regression in the same commit.ADD_WORK_EMAILtoSIDE_EFFECT_REQUEST_COMMANDSinsrc/libs/API/types.tsand wire it intoWRITE_COMMANDSaccordingly.BaseOnboardingWorkEmail.tsx: it already readsonboardingValues?.shouldValidateto navigate to the verification modal andonboardingValues?.isMergingAccountBlockedto swap in the block view, so once the flag is set correctly the UI handles itself.What alternative solutions did you explore?
67adc770546. Removes the regression, but loses the protection for the 2FA-required case the original commit was trying to handle. The side-effect approach above keeps both behaviors.BaseOnboardingWorkEmail.tsxsoshouldValidatewins overisMergingAccountBlocked. Treats the symptom rather than the cause;isMergingAccountBlockedis also persisted to NVP and read byBaseOnboardingWorkEmailValidation.tsx#L100, so the wrong flag would still leak into the validation screen.jsonCode: 200+shouldValidate: truefor existing-member emails). Plausible but out of scope here, and it leaves the frontend's "every failure = blocked" bug in place for any other transient error (timeouts, 5xx, etc.).melvin-bot commentedon May 7, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @truph01 (
External)Abdukhamid000 commentedon May 7, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
[-]Log in - "Verify your work email" is not displayed, unable to merge newAccount[/-][+][$250] Log in - "Verify your work email" is not displayed, unable to merge newAccount[/+]melvin-bot commentedon May 7, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022052300928016840812
KJ21-ENG commentedon May 7, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
aswin-s commentedon May 7, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-05-07 08:26:33 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a brand-new user completes signup and reaches the onboarding "What's your work email?" modal, entering an expensifail email that is already a member of an existing workspace causes the UI to show "Could not add work email" (the
OnboardingMergingAccountBlockedView) instead of the expected "Verify your work email" magic-code screen. The user cannot proceed with onboarding.What is the root cause of that problem?
The bug is in the
AddWorkEmailaction insrc/libs/actions/Session/index.ts(lines 1480–1495).The
failureDatafor theADD_WORK_EMAILAPI call unconditionally setsisMergingAccountBlocked: trueonONYXKEYS.NVP_ONBOARDING:When
BaseOnboardingWorkEmail.tsx(line 162) seesonboardingValues?.isMergingAccountBlocked === true, it replaces the whole form withOnboardingMergingAccountBlockedView— the "Could not add work email" screen.The problem: not every
ADD_WORK_EMAILfailure is a genuine merge-block. In the reproduction steps, the submitted email (account B) is already a workspace member, which causes the server to return an error — but this is not a permanent merge-block situation. The client blindly setsisMergingAccountBlocked: trueanyway, showing the wrong screen.Compare with
MergeIntoAccountAndLogin(line 1568), which usesmakeRequestWithSideEffectsand inspects the response code before settingisMergingAccountBlocked: it only sets the flag when the error is not an invalid-code error.AddWorkEmailhas no such discrimination — it sets the flag on every failure path.Permalink:
App/src/libs/actions/Session/index.ts
Lines 1480 to 1495 in 1b35175
What changes do you think we should make in order to solve the problem?
Switch
AddWorkEmailfromAPI.writetoAPI.makeRequestWithSideEffectsso we can inspect the server response and only setisMergingAccountBlocked: truewhen the server explicitly indicates a merge-block condition. RemoveisMergingAccountBlocked: truefromfailureDataentirely — network/transient failures should not block the user.File:
src/libs/actions/Session/index.tsFunction:
AddWorkEmail(line 1458)This requires adding
ADD_WORK_EMAILtoSIDE_EFFECT_REQUEST_COMMANDSif it isn't already there.Blast radius: Isolated to
AddWorkEmail. TheuseEffectinBaseOnboardingWorkEmailalready handles navigation viashouldValidateon success — that path is unchanged. The only behaviour change is that transient/non-merge-block failures no longer show the permanent blocked screen.What alternative solutions did you explore? (Optional)
Keep
API.writebut removeisMergingAccountBlockedfromfailureDataentirely — simpler, but means merge-block failures also don't show the blocked screen. Not safe since genuine merge-blocks need that UI.Add a separate error key (e.g.
addWorkEmailError) to distinguish failure types without touchingisMergingAccountBlocked— workable but adds Onyx complexity. ThemakeRequestWithSideEffectsapproach is cleaner and consistent with howMergeIntoAccountAndLoginalready handles this.github-actions commentedon May 7, 2026
13 remaining items
melvin-bot commentedon May 19, 2026
Triggered auto assignment to @carlosmiceli, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
carlosmiceli commentedon May 19, 2026
@truph01 what is the question?
truph01 commentedon May 20, 2026
In this test case:
In step 4. Tap "Add Work Email" button -
AddWorkEmailAPI is triggered here. It throws error:@carlosmiceli Could you confirm whether it is expected?
carlosmiceli commentedon May 20, 2026
Yes, the BE intentionally rejects work emails whose domain has SAML/SSO configured, because SSO accounts can't be merged via the magic-code verification flow.
melvin-bot commentedon May 21, 2026
@carlosmiceli @truph01 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!
truph01 commentedon May 22, 2026
@carlosmiceli If so, i think we can close this one
carlosmiceli commentedon May 22, 2026
@jponikarchuk that sounds right, can we close this or will it be reopened?
melvin-bot commentedon May 25, 2026
@carlosmiceli Whoops! This issue is 2 days overdue. Let's get this updated quick!
Abdukhamid000 commentedon May 26, 2026
@carlosmiceli @truph01 so root cause from BE ?