[$175] Onboarding - Explain how to merge when "We couldn't add [work email]" blocks the user
Problem
Some users sign up with a phone number or a personal email. In onboarding, they then enter a work email that already has an Expensify account. They see the generic "We couldn't add [email]" screen, which doesn't say why it failed or how to fix it.
This is the fallback subtitle, onboarding.mergeBlockScreen.subtitle, in src/components/OnboardingMergingAccountBlockedView.tsx. Other merge-account error paths already tell the user the reason and the next step (Figma). This case seems to have been missed.
Solution
When the work email belongs to an existing account, show: "Sign in with [work email] and merge this account from Account > Security > Merge accounts."
Update all supported locales.
Reported in Slack.
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022114731663671120637
- Upwork Job ID: 2114731663671120637
- Last Price Increase: 2026-10-26
Issue Owner
Current Issue Owner: @marcaaron
Triggered auto assignment to Contributor-plus team member for initial proposal review - @dmkt9 (External)
Job added to Upwork: https://www.upwork.com/jobs/~022114731663671120637
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user registers with a personal email or phone number and attempts to add an existing work email during onboarding, they encounter a blocking screen (OnboardingMergingAccountBlockedView) displaying the generic message "We couldn't add [email]". This does not inform the user why the operation failed or guide them on how to resolve the conflict.
What is the root cause of that problem?
The fallback translation string onboarding.mergeBlockScreen.subtitle in the language files (src/languages/en.ts and src/languages/es.ts) contains an uninformative legacy message ("We couldn't add {0}."). OnboardingMergingAccountBlockedView.tsx already calls translate('onboarding.mergeBlockScreen.subtitle', workEmail) as its fallback execution path, but the translation string itself was never updated to match the Figma specification for existing accounts.
What changes do you think we should make in order to solve the problem?
Update the onboarding.mergeBlockScreen.subtitle translation strings in both src/languages/en.ts and src/languages/es.ts to supply actionable instructions to the user. No component logic modifications in src/components/OnboardingMergingAccountBlockedView.tsx are required, ensuring zero regression risk for existing onboarding flows.
src/languages/en.ts
--- a/src/languages/en.ts
+++ b/src/languages/en.ts
@@ -1012,7 +1012,7 @@ const translations = {
onboarding: {
mergeBlockScreen: {
title: "We couldn't add this email",
- subtitle: "We couldn't add {0}.",
+ subtitle: "Sign in with {0} and merge this account from Account > Security > Merge accounts.",
},
},
src/languages/es.ts
--- a/src/languages/es.ts
+++ b/src/languages/es.ts
@@ -1012,7 +1012,7 @@ const translations = {
onboarding: {
mergeBlockScreen: {
title: "No pudimos agregar este correo electrónico",
- subtitle: "No pudimos agregar {0}.",
+ subtitle: "Inicia sesión con {0} y combina esta cuenta desde Cuenta > Seguridad > Combinar cuentas.",
},
},
What alternative solutions did you explore? (Optional)
A naive automated approach (e.g., typical bot proposals) might attempt to refactor getErrorSubtitle() inside src/components/OnboardingMergingAccountBlockedView.tsx by adding state hooks, hardcoded strings, or custom Onyx key conditionals.
- Flaws of naive/bot solutions:
- Unnecessary Component Mutations: Refactoring component logic increases blast radius and introduces rendering side-effects.
- Placeholder Mismatches: Using named placeholders like
{workEmail}or%{email}breaks Expensify'sLocalize.translateparameter interpolation, which expects positional index tokens (i.e.,{0}). - Locale Incompleteness: Failing to update
es.tsalongsideen.tscauses localization key missing warnings or raw untranslated strings for non-English clients.
By restricting changes strictly to the localization dictionary and preserving the {0} parameter signature, we adhere to the KISS principle while delivering a production-ready fix.
What automated tests can you add to prevent this from re-occurring?
Add a unit test in tests/unit/OnboardingMergingAccountBlockedViewTest.tsx verifying that OnboardingMergingAccountBlockedView renders the updated actionable subtitle with correct parameter interpolation.
import {render, screen} from '@testing-library/react-native';
import React from 'react';
import OnboardingMergingAccountBlockedView from '@components/OnboardingMergingAccountBlockedView';
describe('OnboardingMergingAccountBlockedView', () => {
it('renders the correct instructional subtitle when fallback message is active', () => {
const testEmail = '[email protected]';
render(<OnboardingMergingAccountBlockedView workEmail={testEmail} isVsb={false} />);
expect(
screen.getByText(`Sign in with ${testEmail} and merge this account from Account > Security > Merge accounts.`),
).toBeTruthy();
});
});
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01b60d704ba377be83
✅ 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 who signed up with a phone number or a personal email enters, during onboarding, a work email that already belongs to another Expensify account. The "Couldn’t add work email" screen shows only the generic fallback subtitle (onboarding.mergeBlockScreen.subtitle, "We couldn’t add [email]. Please try again later..."), so the user doesn't learn why it failed or how to merge. We want this case to show: "Sign in with [work email] and merge this account from Account > Security > Merge accounts.", in every supported locale.
What is the root cause of that problem?
OnboardingMergingAccountBlockedView picks its subtitle from ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY and only falls back to the generic subtitle when that key is empty:
https://github.com/Expensify/App/blob/e91966a951c4f8f9c4791bedd81b703998839b2b/src/components/OnboardingMergingAccountBlockedView.tsx#L37-L50
The key is set in the .then() of AddWorkEmail in src/libs/actions/Session/index.ts. When the user's current account is already validated (they signed in with their phone or personal email and a magic code) and the work email belongs to an existing account, the backend refuses to merge (takeover protection) and returns jsonCode: 666 with message: "403 Forbidden". That is CONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR ("Returned when an already validated public-domain account tries to add a work email"). The client only turns it into specific copy when the request comes from the Concierge "Add work email" task:
https://github.com/Expensify/App/blob/e91966a951c4f8f9c4791bedd81b703998839b2b/src/libs/actions/Session/index.ts#L1786-L1793
if (addWorkEmailTaskReport && response?.message === CONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR) {
Onyx.merge(ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY, 'onboarding.mergeBlockScreen.validatedPublicDomainSubtitle');
}
Onyx.merge(ONYXKEYS.NVP_ONBOARDING, {isMergingAccountBlocked: true});
In the regular onboarding work-email step, BaseOnboardingWorkEmail calls AddWorkEmail(submittedWorkEmail, addWorkEmailTaskReport) with no task report, so addWorkEmailTaskReport is undefined. The 403 then only sets isMergingAccountBlocked: true, and the view shows the generic fallback. The existing unit test documents this behaviour: tests/unit/AddWorkEmailTest.ts > "blocks the merge on a generic failure" sends exactly this 403 Forbidden response.
A second, smaller path reaches the same fallback: when the user does get the magic code but MergeIntoAccountAndLogin fails for any reason other than an invalid code, it sets isMergingAccountBlocked: true without an error key (Session/index.ts L1858-L1864). At that point the work email is known to belong to an existing account, because the merge step only runs after shouldValidate.
What changes do you think we should make in order to solve the problem?
-
New translation key. Add
onboarding.mergeBlockScreen.existingAccountSubtitlenext to the othermergeBlockScreensubtitles insrc/languages/en.ts, with the same(workEmail: string | undefined)signature asdomainControlledSubtitle:existingAccountSubtitle: (workEmail: string | undefined) => `Sign in with ${workEmail} and merge this account from Account > Security > Merge accounts.`,Add it to every locale in
src/languages/(de, el, es, fr, it, ja, nl, pl, pt-BR, zh-hans), reusing each locale's existing "Account > Security > Merge accounts" path fromvalidatedPublicDomainSubtitleso the menu names match the app, for example:- es:
Inicia sesión con ${workEmail} y fusiona esta cuenta desde Cuenta > Seguridad > Fusionar cuentas. - fr:
Connectez-vous avec ${workEmail} et fusionnez ce compte depuis Compte > Sécurité > Fusionner les comptes. - de:
Melden Sie sich mit ${workEmail} an und führen Sie dieses Konto unter Konto > Sicherheit > Konten zusammenführen zusammen. - ja:
${workEmail} でサインインし、「アカウント」>「セキュリティ」>「アカウントの統合」からこのアカウントを統合してください。
The rest (el, it, nl, pl, pt-BR, zh-hans) follow the same pattern, or come from
scripts/generateTranslations.tsand the Polyglot Parrot diff, reviewed by hand. - es:
-
Set the key for the existing-account rejection in every onboarding flow (
AddWorkEmail,src/libs/actions/Session/index.ts). Drop theaddWorkEmailTaskReport &&gate, so the standard onboarding step and the Concierge task show the same copy:if (response?.message === CONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR) { Onyx.merge(ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY, 'onboarding.mergeBlockScreen.existingAccountSubtitle'); } Onyx.merge(ONYXKEYS.NVP_ONBOARDING, {isMergingAccountBlocked: true});The check stays where it is now, below the
!isOnboardingFlowearly return, and is not added to theerrorTranslationKeychain. On the workspace company-card / Expensify Card forms (#98664), the same 403 must keep showingcommon.genericErrorMessageinline, not onboarding merge instructions. The new key replacesvalidatedPublicDomainSubtitle, which said the same thing in older wording. I'd remove that key and its three references, so we don't keep two strings for one case. -
Merge step failures (
MergeIntoAccountAndLogin, same file). In theelsebranch that blocks the merge, also writeONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY = 'onboarding.mergeBlockScreen.existingAccountSubtitle'. If the message containsCONST.MERGE_ACCOUNT_2FA_ERRORorCONST.MERGE_ACCOUNT_SINGLE_SIGN_ON_ERROR, use the existingonboarding.workEmail2FAError/onboarding.singleSignOnErrorkeys instead, the same mappingAddWorkEmailalready uses. Signing in to the work account and merging from Security is the right recovery for any failure at this point. -
Let the view and the purpose screen pass the email to the new key. In
OnboardingMergingAccountBlockedView.getErrorSubtitleandBaseOnboardingPurpose.getErrorMessage, the email-interpolated keys are compared one by one. AddexistingAccountSubtitleto that branch, using a small shared list (for exampleMERGE_BLOCK_SUBTITLE_KEYS_WITH_EMAILinCONSTor the Welcome actions) instead of growing the===chain in two places:if (onboardingErrorMessage && MERGE_BLOCK_SUBTITLE_KEYS_WITH_EMAIL.has(onboardingErrorMessage)) { return translate(onboardingErrorMessage, workEmail); }The generic
onboarding.mergeBlockScreen.subtitlestays as the fallback for unknown backend errors.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
tests/unit/AddWorkEmailTest.ts, onboarding: a403 Forbiddenresponse with no task report setsisMergingAccountBlocked: trueandONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY = 'onboarding.mergeBlockScreen.existingAccountSubtitle'.- Same file: an unknown error (for example
500) still sets onlyisMergingAccountBlocked, so the generic subtitle remains the fallback. - Same file, workspace card flow: the 403 still shows
common.genericErrorMessageinline and writes no onboarding state (the existing test keeps passing). MergeIntoAccountAndLogin: a non-invalid-code error sets the new key; an invalid code still setscontacts.genericFailureMessages.validateSecondaryLoginand does not block.OnboardingMergingAccountBlockedView: with the new key in Onyx, the subtitle renders the translated copy with the work email.
What alternative solutions did you explore? (Optional)
- Keep
validatedPublicDomainSubtitlefor the Concierge task flow and add the new key only for standard onboarding. This changes less copy, but leaves two near-identical messages for the same backend error. - Change the generic fallback copy to the merge instructions. That's simpler, but the fallback also covers failures where the work email isn't an existing account (unknown backend errors), and the instructions would be wrong there.
- Have the backend return a dedicated error string (like
401 work domain is controlled) for the takeover-protection case instead of a bare403 Forbidden. That's cleaner long-term, but it needs an internal change. The frontend change above works with the current response, and the constant can be swapped later.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user signs up with a phone number or a personal email and then enters a work email that already belongs to an existing Expensify account during onboarding, the blocking screen (OnboardingMergingAccountBlockedView) displays the generic fallback message (onboarding.mergeBlockScreen.subtitle: "We couldn’t add [work email]. Please try again later in Settings or chat with Concierge for guidance."). Unlike the other merge-block paths, this message does not explain why adding the email failed or how the user can merge their accounts.
What is the root cause of that problem?
In src/components/OnboardingMergingAccountBlockedView.tsx, getErrorSubtitle() checks ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY for specific merge-block reasons (validatedPublicDomainSubtitle, domainControlledSubtitle, workAccountClosedSubtitle) and otherwise falls back to translate('onboarding.mergeBlockScreen.subtitle', workEmail):
const getErrorSubtitle = () => {
if (onboardingErrorMessage === 'onboarding.mergeBlockScreen.validatedPublicDomainSubtitle') {
return translate(onboardingErrorMessage, workEmail);
}
// This subtitle interpolates the work email, so translate it with the email explicitly.
if (onboardingErrorMessage === 'onboarding.mergeBlockScreen.domainControlledSubtitle') {
return translate('onboarding.mergeBlockScreen.domainControlledSubtitle', workEmail);
}
if (onboardingErrorMessage) {
return translate(onboardingErrorMessage);
}
// Fallback to generic error message
return translate('onboarding.mergeBlockScreen.subtitle', workEmail);
};
There are two onboarding flows where an existing work account triggers isMergingAccountBlocked: true while leaving ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY unset (null), hitting onboarding.mergeBlockScreen.subtitle:
- Validated personal-email / phone-number login in standard onboarding (
AddWorkEmailinsrc/libs/actions/Session/index.ts): When the current account is already validated and tries to add an existing work email, the backend rejects the merge withCONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR('403 Forbidden'). BecauseSession/index.tsgatesvalidatedPublicDomainSubtitlebehindif (addWorkEmailTaskReport && response?.message === CONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR), standard onboarding (whereaddWorkEmailTaskReportisundefined) only setsOnyx.merge(ONYXKEYS.NVP_ONBOARDING, {isMergingAccountBlocked: true})with no error translation key. - Account merge blocked during
MergeIntoAccountAndLogin(src/libs/actions/Session/index.tsandtests/ui/WorkEmailOnboarding.tsx): When an unvalidated user enters a work email belonging to an existing account (shouldValidate: true) and submits the validation code toMergeIntoAccountAndLogin, the backend blocks non-mergeable accounts either by returningisMergingAccountBlocked: trueinonyxData(e.g.,jsonCode: 501inMergeIntoAccountAndLoginBlockMergeattests/ui/WorkEmailOnboarding.tsx#L150-L166) or via theelsebranch ofresponse?.jsonCode === CONST.JSON_CODE.EXP_ERROR(666). In both cases,ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEYwas cleared tonullinoptimisticData, soOnboardingMergingAccountBlockedViewrendersonboarding.mergeBlockScreen.subtitle.
Because onboarding.mergeBlockScreen.subtitle in src/languages/*.ts still holds the legacy copy ("We couldn’t add ${workEmail}. Please try again later in Settings or chat with Concierge for guidance."), the user is not told to sign in with their work email and merge from Account > Security > Merge accounts.
What changes do you think we should make in order to solve the problem?
Update onboarding.mergeBlockScreen.subtitle across all 11 supported locale files (src/languages/en.ts, de.ts, el.ts, es.ts, fr.ts, it.ts, ja.ts, nl.ts, pl.ts, pt-BR.ts, zh-hans.ts), preserving the (workEmail: string | undefined) => string function signature and using each locale's exact navigation path for Account > Security > Merge accounts:
src/languages/en.ts
subtitle: (workEmail: string | undefined) => `Sign in with ${workEmail} and merge this account from Account > Security > Merge accounts.`,
src/languages/de.ts
subtitle: (workEmail: string | undefined) =>
`Melden Sie sich mit ${workEmail} an und führen Sie dieses Konto unter Konto > Sicherheit > Konten zusammenführen zusammen.`,
src/languages/el.ts
subtitle: (workEmail: string | undefined) =>
`Συνδεθείτε με το ${workEmail} και συγχωνεύστε αυτόν τον λογαριασμό από Λογαριασμός > Ασφάλεια > Συγχώνευση λογαριασμών.`,
src/languages/es.ts
subtitle: (workEmail: string | undefined) => `Inicia sesión con ${workEmail} y fusiona esta cuenta desde Cuenta > Seguridad > Fusionar cuentas.`,
src/languages/fr.ts
subtitle: (workEmail: string | undefined) =>
`Connectez-vous avec ${workEmail} et fusionnez ce compte depuis Compte > Sécurité > Fusionner les comptes.`,
src/languages/it.ts
subtitle: (workEmail: string | undefined) =>
`Accedi con ${workEmail} e unisci questo account da Account > Sicurezza > Unisci account.`,
src/languages/ja.ts(matchingsecurityPage.mergeAccount'アカウントを統合')
subtitle: (workEmail: string | undefined) =>
`${workEmail} でサインインし、「アカウント」>「セキュリティ」>「アカウントを統合」からこのアカウントを統合してください。`,
src/languages/nl.ts
subtitle: (workEmail: string | undefined) => `Log in met ${workEmail} en voeg dit account samen via Account > Beveiliging > Accounts samenvoegen.`,
src/languages/pl.ts(matchingcommon.security'Bezpieczeństwo'andsecurityPage.mergeAccount'Połącz konta')
subtitle: (workEmail: string | undefined) => `Zaloguj się za pomocą ${workEmail} i połącz to konto w Konto > Bezpieczeństwo > Połącz konta.`,
src/languages/pt-BR.ts
subtitle: (workEmail: string | undefined) =>
`Entre com ${workEmail} e mescle esta conta em Conta > Segurança > Mesclar contas.`,
src/languages/zh-hans.ts
subtitle: (workEmail: string | undefined) => `请使用 ${workEmail} 登录,并从“账户 > 安全 > 合并账户”合并此账户。`,
- Automated Tests (
tests/ui/WorkEmailOnboarding.tsx)
- Existing test
'should display onboarding merge block screen content correctly'intests/ui/WorkEmailOnboarding.tsx(L1287-L1314) already assertsexpect(screen.getByText(TestHelper.translateLocal('onboarding.mergeBlockScreen.subtitle', workEmail))).toBeOnTheScreen()afterMergeIntoAccountAndLoginBlockMerge(). - Add an explicit test verifying that when
AddWorkEmailis rejected with403 Forbiddenduring standard onboarding (without a Concierge task report),OnboardingMergingAccountBlockedViewrenders the updatedonboarding.mergeBlockScreen.subtitleinterpolated withworkEmail.
What alternative solutions did you explore? (Optional)
We also evaluated keeping onboarding.mergeBlockScreen.subtitle for unknown AddWorkEmail 666 failures and introducing a dedicated key (onboarding.mergeBlockScreen.existingAccountSubtitle) set when the work email belongs to an existing account.
- Updating
onboarding.mergeBlockScreen.subtitledirectly matches the issue specification verbatim ("This is the fallback subtitle,onboarding.mergeBlockScreen.subtitle, insrc/components/OnboardingMergingAccountBlockedView.tsx... Solution: When the work email belongs to an existing account, show: 'Sign in with [work email] and merge this account from Account > Security > Merge accounts.' Update all supported locales"), covers bothAddWorkEmail(403 Forbidden) andMergeIntoAccountAndLogin(501viaonyxDataand666), and avoids writing an email-parameterized key toONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY. - If we instead want unknown
AddWorkEmail666errors (e.g.,500) to retain the generic fallback while existing-account blocks show the merge instructions viaonboarding.mergeBlockScreen.existingAccountSubtitle, three things must be handled together so no path breaks:- In
AddWorkEmail(src/libs/actions/Session/index.ts#L1790), setONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEYto'onboarding.mergeBlockScreen.existingAccountSubtitle'wheneverresponse?.message === CONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR(removing theaddWorkEmailTaskReport &&gate). - In
MergeIntoAccountAndLogin(src/libs/actions/Session/index.ts#L1858-L1873), set'onboarding.mergeBlockScreen.existingAccountSubtitle'both in theresponse?.jsonCode === CONST.JSON_CODE.EXP_ERROR(666) non-invalid-code branch and whenonboardingUpdate?.valuesetsisMergingAccountBlocked: true(such asjsonCode: 501inMergeIntoAccountAndLoginBlockMergeattests/ui/WorkEmailOnboarding.tsx#L150-L166, which bypasses thejsonCode === 666branch). - In
src/pages/OnboardingWorkEmail/BaseOnboardingWorkEmail.tsx#L282-L291, passworkEmail(or skipmergeBlockScreenkeys) when callingaddWorkEmailFormError(translate(workEmailErrorTranslationKey, workEmail)), because callingtranslate(workEmailErrorTranslationKey)withoutworkEmailinterpolates"undefined"into the form error state.
- In
Contributor Details
- Your Expensify account email: [email protected]
- Upwork Profile Link: https://www.upwork.com/freelancers/~016c1aa34b51059d42
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user enters a work email during onboarding that belongs to an existing Expensify account, the blocking screen displays a generic error message ("We couldn’t add [work email]. Please try again later in Settings or chat with Concierge for guidance.") instead of explaining how to sign in with the work email and merge the accounts.
What is the root cause of that problem?
In src/libs/actions/Session/index.ts (lines 1790–1792):
if (addWorkEmailTaskReport && response?.message === CONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR) {
Onyx.merge(ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY, 'onboarding.mergeBlockScreen.validatedPublicDomainSubtitle');
}
ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEYis only set to'onboarding.mergeBlockScreen.validatedPublicDomainSubtitle'whenaddWorkEmailTaskReportis defined (i.e. task-based Concierge flow). In standard onboarding,addWorkEmailTaskReportisundefined.- As a result, standard onboarding sets
isMergingAccountBlocked: truewithout settingONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY. - In
src/components/OnboardingMergingAccountBlockedView.tsx(lines 48–49),getErrorSubtitlefalls back toonboarding.mergeBlockScreen.subtitle:// Fallback to generic error message return translate('onboarding.mergeBlockScreen.subtitle', workEmail); - Additionally,
validatedPublicDomainSubtitleinsrc/languages/en.tsstill contains the older phrasing rather than the requested concise copy:Sign in with [work email] and merge this account from Account > Security > Merge accounts.
What changes do you think we should make in order to solve the problem?
- In
src/libs/actions/Session/index.ts: Remove theaddWorkEmailTaskReport &&condition so that anyCONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERRORduring onboarding sets'onboarding.mergeBlockScreen.validatedPublicDomainSubtitle':- if (addWorkEmailTaskReport && response?.message === CONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR) { + if (response?.message === CONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR) { Onyx.merge(ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY, 'onboarding.mergeBlockScreen.validatedPublicDomainSubtitle'); } - Update
validatedPublicDomainSubtitleacross all 11 supported locales insrc/languages/*.ts:en.ts:(workEmail) => \Sign in with ${workEmail} and merge this account from Account > Security > Merge accounts.``es.ts:(workEmail) => \Inicia sesión con ${workEmail} y fusiona esta cuenta desde Cuenta > Seguridad > Fusionar cuentas.``de.ts:(workEmail) => \Melden Sie sich mit ${workEmail} an und führen Sie dieses Konto unter Konto > Sicherheit > Konten zusammenführen zusammen.``fr.ts:(workEmail) => \Connectez-vous avec ${workEmail} et fusionnez ce compte depuis Compte > Sécurité > Fusionner les comptes.``it.ts:(workEmail) => \Accedi con ${workEmail} e unisci questo account da Account > Sicurezza > Unisci account.``nl.ts:(workEmail) => \Meld je aan met ${workEmail} en voeg dit account samen via Account > Beveiliging > Accounts samenvoegen.``pl.ts:(workEmail) => \Zaloguj się jako ${workEmail} i scal to konto w Konto > Zabezpieczenia > Scal konta.``pt-BR.ts:(workEmail) => \Faça login com ${workEmail} e mescle esta conta em Conta > Segurança > Mesclar contas.``ja.ts:(workEmail) => \${workEmail} でサインインし、「アカウント」>「セキュリティ」>「アカウントの統合」からこのアカウントを統合してください。``zh-hans.ts:(workEmail) => \使用 ${workEmail} 登录,并在“账户 > 安全 > 合并账户”中合并此账户。``el.ts:(workEmail) => \Συνδεθείτε με το ${workEmail} και συγχωνεύστε αυτόν τον λογαριασμό από Λογαριασμός > Ασφάλεια > Συγχώνευση λογαριασμών.``
What alternative solutions did you explore? (Optional)
Changing onboarding.mergeBlockScreen.subtitle fallback directly instead of validatedPublicDomainSubtitle:
Rejected because subtitle is used as the generic fallback for unspecified errors, while validatedPublicDomainSubtitle specifically handles existing validated public domain accounts. Removing the addWorkEmailTaskReport guard correctly categorizes existing account errors across all onboarding entry points.
Tested Branch & Commit
- Branch:
fix/105015-explain-how-to-merge-work-email - Commit:
e9e6cfcf
Proposal
Please re-state the problem that we are trying to solve in this issue.
A user signs up with a personal email or phone number, then enters a work email that already belongs to another Expensify account during onboarding. The merge-blocked screen shows only the generic fallback "We couldn't add [work email]", with no reason for the failure and no next step for the user.
What is the root cause of that problem?
OnboardingMergingAccountBlockedView dispatches on ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY: validatedPublicDomainSubtitle and domainControlledSubtitle each get a specific subtitle, but the existing-account failure sets no specific key, so getErrorSubtitle falls through to the generic onboarding.mergeBlockScreen.subtitle. The component already receives workEmail; it simply has no existing-account branch to use it with.
What changes are you going to make to fix the problem?
- Add a new locale string, for example onboarding.mergeBlockScreen.existingAccountSubtitle: "Sign in with [work email] and merge this account from Account > Security > Merge accounts." (wording per the issue).
- Set ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY to that key at the point where the work-email add fails specifically because the email belongs to an existing account, alongside the existing keys.
- Add the branch in getErrorSubtitle in OnboardingMergingAccountBlockedView.tsx, passing workEmail, so the specific message renders only for this failure.
- Add the string to all supported locale files, keeping the generic subtitle as the fallback for every other failure, so no other error path is mislabelled.
What will you verify?
Repro: sign up with a personal email, enter an existing work email in onboarding, and confirm the blocked screen now shows the sign-in-and-merge instruction with the work email interpolated. Confirm other merge-block reasons still show their own (or the generic) subtitle, and that the confirm-button flow back to the onboarding purpose/employees step is unchanged.
Proposal
Please re-state the problem that we are trying to solve in this issue.
During onboarding, when a user signs up with a personal email or phone number and attempts to add a work email that already belongs to another existing Expensify account, the blocking screen (OnboardingMergingAccountBlockedView) displays an unhelpful generic error message ("We couldn't add [work email]...") instead of explaining that they should sign in with the work email and merge from Account > Security > Merge accounts.
What is the root cause of that problem?
In src/libs/actions/Session/index.ts (lines 1786–1794):
When attempting to add an existing work email during onboarding, specific error keys are only set for WORK_DOMAIN_CONTROLLED_ERROR and WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR. When the error is due to the work email already belonging to another account (e.g. ALREADY_EXISTS / standard merge conflict), no specific translation key is merged into ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY.
As a result, OnboardingMergingAccountBlockedView.tsx (getErrorSubtitle, lines 48-50) falls through to the generic fallback subtitle:
translate('onboarding.mergeBlockScreen.subtitle', workEmail)
which does not inform the user why it failed or how to merge.
What changes do you think we should make in order to solve the problem?
- Add new localized translation keys:
In
src/languages/en.ts(andsrc/languages/es.ts):
onboarding: {
mergeBlockScreen: {
...
existingAccountSubtitle: 'Sign in with {0} and merge this account from Account > Security > Merge accounts.',
},
},
- Set the specific translation key on merge conflict:
In
src/libs/actions/Session/index.tsinside the error handler for adding work email: Identify when the backend returns the error indicating the email already exists on another account, and merge the new translation key:
Onyx.merge(ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY, 'onboarding.mergeBlockScreen.existingAccountSubtitle');
- Handle interpolation in the blocked view:
In
src/components/OnboardingMergingAccountBlockedView.tsx, insidegetErrorSubtitle: Ensure the new key interpolatesworkEmail:
if (
onboardingErrorMessage === 'onboarding.mergeBlockScreen.validatedPublicDomainSubtitle' ||
onboardingErrorMessage === 'onboarding.mergeBlockScreen.domainControlledSubtitle' ||
onboardingErrorMessage === 'onboarding.mergeBlockScreen.existingAccountSubtitle'
) {
return translate(onboardingErrorMessage, workEmail);
}
What alternative solutions did you explore? (Optional)
Changing the generic fallback string directly; however, that fallback is also used for other unexpected network/server errors during merge, so introducing an explicit dedicated translation key preserves distinct messaging for genuine server errors versus existing-account merge guidance.
Test Result / Verification:
- Sign up for a new account using a phone number or personal email.
- In the onboarding flow, proceed to the step prompting to add a work email.
- Enter an email address that already belongs to an existing Expensify account.
- Verify the blocked view title and subtitle clearly state: "Sign in with [work email] and merge this account from Account > Security > Merge accounts."
- Verify the email placeholder
{0}correctly displays the entered work email. - Switch application language to Spanish and confirm the localized subtitle renders correctly.
Proposal
Please re-state the problem that we are trying to solve in this issue.
During onboarding, when a user who signed up with a phone number or personal email attempts to add a work email that already belongs to an existing Expensify account, the blocked screen (OnboardingMergingAccountBlockedView) displays an uninformative generic fallback subtitle ("We couldn't add [email]. Please try again later in Settings or chat with Concierge for guidance.") instead of guiding the user to sign in with their work email and merge accounts from Account > Security > Merge accounts.
What is the root cause of that problem?
- In
src/libs/actions/Session/index.ts(AddWorkEmail, lines 1785–1794), specific translation keys forONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEYare only merged whenresponse?.messageequalsCONST.WORK_DOMAIN_CONTROLLED_ERRORorCONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR. When the work email belongs to an existing account (or causes a merge conflict rejection without matching those two strings),errorTranslationKeyis undefined, andONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEYis not updated before settingisMergingAccountBlocked: true. - In
src/components/OnboardingMergingAccountBlockedView.tsx(getErrorSubtitle, lines 37–50), becauseonboardingErrorMessageis unset/undefined, the component falls through to the generic fallback on line 49:return translate('onboarding.mergeBlockScreen.subtitle', workEmail);which displays the generic "We couldn't add [work email]" message without explanation or next steps.
What changes do you think we should make in order to solve the problem?
-
Locale updates: In
src/languages/en.tsandsrc/languages/es.tsunderonboarding.mergeBlockScreen, addexistingAccountSubtitle:- EN:
(workEmail: string | undefined) => \Sign in with ${workEmail} and merge this account from Account > Security > Merge accounts.`` - ES:
(workEmail: string | undefined) => \Inicia sesión con ${workEmail} y fusiona esta cuenta desde Cuenta > Seguridad > Fusionar cuentas.`*(Note: Alternatively,validatedPublicDomainSubtitle` already contains this exact string and can be reused as the standard merge-account instruction).*
- EN:
-
Session action update: In
src/libs/actions/Session/index.ts(AddWorkEmailerror handling, lines 1785–1794): Whenresponse?.jsonCode === CONST.JSON_CODE.EXP_ERRORduring onboarding and the response indicates the email belongs to an existing account (or as the default blocking subtitle when adding an existing work email), setONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEYto'onboarding.mergeBlockScreen.existingAccountSubtitle'(or'onboarding.mergeBlockScreen.validatedPublicDomainSubtitle'). -
Blocked view subtitle interpolation: In
src/components/OnboardingMergingAccountBlockedView.tsx(getErrorSubtitle, lines 37–44): HandleexistingAccountSubtitlealongsidevalidatedPublicDomainSubtitleanddomainControlledSubtitleto interpolateworkEmailviatranslate(onboardingErrorMessage, workEmail).
What alternative solutions did you explore? (Optional)
- Directly updating the generic fallback string
onboarding.mergeBlockScreen.subtitle: Rejected because that fallback is also triggered on unexpected network or server failures where advising the user to sign in with that email would be inaccurate. Using an explicit key ensures targeted guidance for existing account conflicts while preserving generic messaging for true unexpected errors.
Verification / Tests
- Sign up with a personal email or phone number.
- In the onboarding flow, proceed to the step prompting to add a work email.
- Enter a work email that already has an Expensify account.
- Verify the blocked view renders: "Sign in with [work email] and merge this account from Account > Security > Merge accounts." with the entered email correctly interpolated.
- Verify the Spanish translation displays accurately when the app language is switched to Spanish.
- Verify unit tests in
tests/unit/AddWorkEmailTest.tspass and add a test case verifyingONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEYis set on existing account merge rejection.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~016c1aa34b51059d42
✅ 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 with a phone number or personal email and then enters a work email during onboarding that already belongs to an existing Expensify account, OnboardingMergingAccountBlockedView displays the generic fallback subtitle (onboarding.mergeBlockScreen.subtitle: "We couldn’t add [work email]. Please try again later in Settings or chat with Concierge for guidance.") instead of instructing the user to sign in with their work email and merge from Account > Security > Merge accounts.
What is the root cause of that problem?
In src/components/OnboardingMergingAccountBlockedView.tsx (getErrorSubtitle, lines 37–50), when ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY is not set to one of the specific error keys (validatedPublicDomainSubtitle, domainControlledSubtitle, or workAccountClosedSubtitle), it falls back to translate('onboarding.mergeBlockScreen.subtitle', workEmail):
const getErrorSubtitle = () => {
if (onboardingErrorMessage === 'onboarding.mergeBlockScreen.validatedPublicDomainSubtitle') {
return translate(onboardingErrorMessage, workEmail);
}
// This subtitle interpolates the work email, so translate it with the email explicitly.
if (onboardingErrorMessage === 'onboarding.mergeBlockScreen.domainControlledSubtitle') {
return translate('onboarding.mergeBlockScreen.domainControlledSubtitle', workEmail);
}
if (onboardingErrorMessage) {
return translate(onboardingErrorMessage);
}
// Fallback to generic error message
return translate('onboarding.mergeBlockScreen.subtitle', workEmail);
};
There are two onboarding existing-account rejection paths that set isMergingAccountBlocked: true while leaving ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY unset (null), landing on onboarding.mergeBlockScreen.subtitle:
- Standard onboarding
AddWorkEmail(src/libs/actions/Session/index.ts, lines 1790–1793): When a validated personal-email/phone user attempts to add an existing work email, the backend returnsCONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR('403 Forbidden'). Because settingvalidatedPublicDomainSubtitleis gated behindif (addWorkEmailTaskReport && response?.message === CONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR), standard onboarding (whereaddWorkEmailTaskReportisundefined) only writesOnyx.merge(ONYXKEYS.NVP_ONBOARDING, {isMergingAccountBlocked: true}). - Blocked merge during
MergeIntoAccountAndLogin(src/libs/actions/Session/index.ts, lines 1858–1866): WhenMergeIntoAccountAndLoginblocks merging into the existing work account (isMergingAccountBlocked: trueviaonyxDataorjsonCode === 666),ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEYwas cleared tonullinoptimisticData, soOnboardingMergingAccountBlockedViewrendersonboarding.mergeBlockScreen.subtitle.
Because onboarding.mergeBlockScreen.subtitle in src/languages/*.ts still holds the legacy generic message ("We couldn’t add ${workEmail}. Please try again later in Settings or chat with Concierge for guidance."), the user is not told how to merge.
What changes do you think we should make in order to solve the problem?
Update onboarding.mergeBlockScreen.subtitle across all 11 supported locale files in src/languages/ (en.ts, de.ts, el.ts, es.ts, fr.ts, it.ts, ja.ts, nl.ts, pl.ts, pt-BR.ts, zh-hans.ts), preserving the (workEmail: string | undefined) => string function signature and using each locale's exact navigation path for Account > Security > Merge accounts:
src/languages/en.ts(line 3689)
// Before
subtitle: (workEmail: string | undefined) => `We couldn’t add ${workEmail}. Please try again later in Settings or chat with Concierge for guidance.`,
// After
subtitle: (workEmail: string | undefined) => `Sign in with ${workEmail} and merge this account from Account > Security > Merge accounts.`,
src/languages/de.ts(lines 3537–3538)
// Before
subtitle: (workEmail: string | undefined) =>
`Wir konnten ${workEmail} nicht hinzufügen. Bitte versuche es später in den Einstellungen erneut oder chatte mit Concierge, um Unterstützung zu erhalten.`,
// After
subtitle: (workEmail: string | undefined) =>
`Melden Sie sich mit ${workEmail} an und führen Sie dieses Konto unter Konto > Sicherheit > Konten zusammenführen zusammen.`,
src/languages/el.ts(line 3586)
// Before
subtitle: (workEmail: string | undefined) => `Δεν ήταν δυνατή η Ï€Ïοσθήκη του ${workEmail}. Δοκιμάστε ξανά αÏγότεÏα στις Ïυθμίσεις ή συνομιλήστε με το Concierge για καθοδήγηση.`,
// After
subtitle: (workEmail: string | undefined) =>
`Συνδεθείτε με το ${workEmail} και συγχωνεÏστε αυτόν τον λογαÏιασμό από ΛογαÏιασμός > Ασφάλεια > Συγχώνευση λογαÏιασμών.`,
src/languages/es.ts(line 3427)
// Before
subtitle: (workEmail) => `No pudimos añadir ${workEmail}. Por favor, inténtalo de nuevo más tarde en Configuración o chatea con Concierge para obtener ayuda.`,
// After
subtitle: (workEmail: string | undefined) => `Inicia sesión con ${workEmail} y fusiona esta cuenta desde Cuenta > Seguridad > Fusionar cuentas.`,
src/languages/fr.ts(lines 3544–3545)
// Before
subtitle: (workEmail: string | undefined) =>
`Nous n’avons pas pu ajouter ${workEmail}. Veuillez réessayer plus tard dans les Paramètres ou discuter avec Concierge pour obtenir de l’aide.`,
// After
subtitle: (workEmail: string | undefined) =>
`Connectez-vous avec ${workEmail} et fusionnez ce compte depuis Compte > Sécurité > Fusionner les comptes.`,
src/languages/it.ts(lines 3521–3522)
// Before
subtitle: (workEmail: string | undefined) =>
`Non è stato possibile aggiungere ${workEmail}. Riprova più tardi in Impostazioni oppure chatta con Concierge per ricevere assistenza.`,
// After
subtitle: (workEmail: string | undefined) =>
`Accedi con ${workEmail} e unisci questo account da Account > Sicurezza > Unisci account.`,
src/languages/ja.ts(lines 3493–3494)
// Before
subtitle: (workEmail: string | undefined) =>
`${workEmail} ã‚’è¿½åŠ ã§ãã¾ã›ã‚“ã§ã—ãŸã€‚後ã§ã€Œè¨å®šã€ã‹ã‚‰ã‚‚ã†ä¸€åº¦ãŠè©¦ã—ã„ãŸã ãã‹ã€ã‚¬ã‚¤ãƒ€ãƒ³ã‚¹ã«ã¤ã„㦠Concierge ã«ãƒãƒ£ãƒƒãƒˆã§ãŠå•ã„åˆã‚ã›ãã ã•ã„。`,
// After
subtitle: (workEmail: string | undefined) =>
`${workEmail} ã§ã‚µã‚¤ãƒ³ã‚¤ãƒ³ã—ã€ã€Œã‚¢ã‚«ã‚¦ãƒ³ãƒˆã€ï¼žã€Œã‚»ã‚ュリティã€ï¼žã€Œã‚¢ã‚«ã‚¦ãƒ³ãƒˆã‚’çµ±åˆã€ã‹ã‚‰ã“ã®ã‚¢ã‚«ã‚¦ãƒ³ãƒˆã‚’çµ±åˆã—ã¦ãã ã•ã„。`,
src/languages/nl.ts(line 3525)
// Before
subtitle: (workEmail: string | undefined) => `We konden ${workEmail} niet toevoegen. Probeer het later opnieuw in Instellingen of chat met Concierge voor hulp.`,
// After
subtitle: (workEmail: string | undefined) => `Log in met ${workEmail} en voeg dit account samen via Account > Beveiliging > Accounts samenvoegen.`,
src/languages/pl.ts(line 3558)
// Before
subtitle: (workEmail: string | undefined) => `Nie udało się dodać ${workEmail}. Spróbuj ponownie później w Ustawieniach lub porozmawiaj z Concierge, aby uzyskać pomoc.`,
// After
subtitle: (workEmail: string | undefined) => `Zaloguj się za pomocą ${workEmail} i połącz to konto w Konto > Bezpieczeństwo > Połącz konta.`,
src/languages/pt-BR.ts(lines 3512–3513)
// Before
subtitle: (workEmail: string | undefined) =>
`Não foi possÃvel adicionar ${workEmail}. Tente novamente mais tarde em Configurações ou converse com o Concierge para obter orientação.`,
// After
subtitle: (workEmail: string | undefined) =>
`Entre com ${workEmail} e mescle esta conta em Conta > Segurança > Mesclar contas.`,
src/languages/zh-hans.ts(line 3403)
// Before
subtitle: (workEmail: string | undefined) => `æˆ‘ä»¬æ— æ³•æ·»åŠ ${workEmail}。请ç¨åŽåœ¨è®¾ç½®ä¸é‡è¯•,或与 Concierge èŠå¤©ä»¥èŽ·å–æŒ‡å¯¼ã€‚`,
// After
subtitle: (workEmail: string | undefined) => `请使用 ${workEmail} 登录,并从“账户 > 安全 > åˆå¹¶è´¦æˆ·â€åˆå¹¶æ¤è´¦æˆ·ã€‚`,
What alternative solutions did you explore? (Optional)
We also considered introducing a separate onboarding.mergeBlockScreen.existingAccountSubtitle key and setting it in AddWorkEmail and MergeIntoAccountAndLogin while leaving onboarding.mergeBlockScreen.subtitle untouched. However, the issue description explicitly specifies updating the fallback subtitle onboarding.mergeBlockScreen.subtitle in OnboardingMergingAccountBlockedView.tsx across all supported locales, which cleanly covers both the 403 Forbidden path in AddWorkEmail and the blocked merge path in MergeIntoAccountAndLogin (501 via onyxData and 666) without extra Onyx state mutations.
@MelvinBot submit a proposal
Proposal
Please re-state the problem that we are trying to solve in this issue.
During onboarding, a user who signed up with a phone number or personal email enters a work email that already has an Expensify account. The blocked screen shows the generic "We couldn’t add [email]…" subtitle, so the user doesn't know why or how to fix it.
What is the root cause of that problem?
The app already has merge guidance copy for this exact backend error (validatedPublicDomainSubtitle), but it only sets it for the Concierge "Add work email" task. In regular onboarding the task report is undefined, so the 403 Forbidden response (CONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR) only sets isMergingAccountBlocked. The view then falls back to the generic subtitle.
A second path has the same result. If the user does validate the work email but MergeIntoAccountAndLogin fails for any reason other than a wrong code, no error key is set, so the generic subtitle shows again.
Code references
- The guidance key is gated on the task report:
src/libs/actions/Session/index.ts:1790-1793 - Regular onboarding calls
AddWorkEmailwithout a task report:src/pages/OnboardingWorkEmail/BaseOnboardingWorkEmail.tsx:272. Validated users stay on this screen while guided setup is incomplete:BaseOnboardingWorkEmail.tsx:203-209 MergeIntoAccountAndLoginblocks without an error key:src/libs/actions/Session/index.ts:1858-1864- The view falls back to the generic subtitle:
src/components/OnboardingMergingAccountBlockedView.tsx:37-50 - The existing guidance copy:
src/languages/en.ts:3691-3692 - The meaning of
403 Forbiddencomes from the comment onsrc/CONST/index.ts:7920-7921. The backend is outside this repo, so I couldn't confirm that phone-number accounts get the same response.
What changes do you think we should make in order to solve the problem?
- In
AddWorkEmail, remove theaddWorkEmailTaskReport &&condition. Every onboarding403 Forbiddenresponse then setsonboarding.mergeBlockScreen.validatedPublicDomainSubtitle. Keep the check below the!isOnboardingFlowreturn, so the workspace card forms still show their inline generic error. - In
MergeIntoAccountAndLogin, when the error is not an invalid code, also set an error key before blocking. Useonboarding.workEmail2FAErrororonboarding.singleSignOnErrorwhen the message matches those errors, the same wayAddWorkEmaildoes. Otherwise usevalidatedPublicDomainSubtitle. At this point the user has proven they own the existing work account, so the merge guidance applies. - Change the
validatedPublicDomainSubtitlecopy to the requested wording in all 11 locales: "Sign in with ${workEmail} and merge this account from Account > Security > Merge accounts." Reuse each locale's existing menu path from the current string, and keep each file's quote style. - No change is needed in
OnboardingMergingAccountBlockedVieworBaseOnboardingPurpose. Both already pass the work email to this key. - Tests:
tests/unit/AddWorkEmailTest.ts: an onboarding403 Forbiddenwith no task report sets the guidance key, and an unknown error still sets no key.tests/ui/WorkEmailOnboarding.tsx: update the blocked-merge test at line 1309 to expect the guidance copy, and add a regular onboarding case for the 403.
What alternative solutions did you explore? (Optional)
- Add a new
existingAccountSubtitlekey. This leaves two strings for the same backend error, so I'd reuse the existing key. - Change the generic
subtitlecopy. That fallback also covers unknown errors where the email may not belong to an existing account, so the merge instructions could be wrong there.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/105015#issuecomment-6444284603) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
@MelvinBot handle the jsonCode: 501 case as well
Proposal (updated: handles the jsonCode: 501 blocked-merge response)
Please re-state the problem that we are trying to solve in this issue.
During onboarding, a user who signed up with a phone number or personal email enters a work email that already has an Expensify account. The blocked screen shows the generic "We couldn’t add [email]…" subtitle, so the user doesn't know why or how to fix it.
What is the root cause of that problem?
The app already has merge guidance copy (validatedPublicDomainSubtitle), but three paths reach the blocked screen without setting it, so the view falls back to the generic subtitle:
AddWorkEmailreturns403 Forbidden. The guidance key is only set when there is a Concierge task report. Regular onboarding passes no task report.MergeIntoAccountAndLoginreturnsjsonCode: 666with an error other than a wrong code. That branch setsisMergingAccountBlockedbut no error key.MergeIntoAccountAndLoginreturnsjsonCode: 501. The backend blocks the merge by sendingisMergingAccountBlocked: trueinonyxData. The.thenhandler only checks for666, so a501falls through to the success path. There it finds noauthToken, returnsdidMerge: false, and never sets an error key.
Code references
AddWorkEmailgates the guidance key on the task report:src/libs/actions/Session/index.ts:1810-1813. Regular onboarding calls it without one:BaseOnboardingWorkEmail.tsx:272- The
666branch blocks without an error key:src/libs/actions/Session/index.ts:1878-1886 - A
501skips that branch and returns through the no-authTokenpath:src/libs/actions/Session/index.ts:1888-1902. The handler already reads theNVP_ONBOARDINGupdate fromonyxDataat line 1889. SaveResponseInOnyxapplies the responseonyxDatafor anyjsonCode, which is howisMergingAccountBlocked: truereaches Onyx:src/libs/actions/OnyxUpdates.ts:74- The
501response shape is mocked intests/ui/WorkEmailOnboarding.tsx:150-166. The test at line 1309 currently expects the generic subtitle for it. - The view falls back to the generic subtitle:
src/components/OnboardingMergingAccountBlockedView.tsx:37-50 - The existing guidance copy:
src/languages/en.ts:3984
The backend is outside this repo. I couldn't confirm which production cases return 501 and which return 666, so the fix covers both.
What changes do you think we should make in order to solve the problem?
AddWorkEmail: remove theaddWorkEmailTaskReport &&condition, so every onboarding403 Forbiddensetsonboarding.mergeBlockScreen.validatedPublicDomainSubtitle. Keep it below the!isOnboardingFlowreturn, so the workspace card forms still show their inline generic error.MergeIntoAccountAndLogin: add a small helper that picks the error key from the response message. It returnsonboarding.workEmail2FAErrororonboarding.singleSignOnErrorwhen the message matches, likeAddWorkEmaildoes. Otherwise it returnsvalidatedPublicDomainSubtitle. Use it in two places:666, not a wrong code: set the key before settingisMergingAccountBlocked.501: after readingonboardingUpdate, check whether its value hasisMergingAccountBlocked: true. If so, set the key and return{didMerge: false, shouldRedirectToClassicAfterMerge: false, conciergeReportID: undefined}early, skipping theauthTokenpath. Check theonyxDataflag rather than the raw501, because the flag is what shows the blocked screen.CONST.JSON_CODEalso has no501entry.
- Copy: change
validatedPublicDomainSubtitleto the requested wording in all 11 locales: "Sign in with ${workEmail} and merge this account from Account > Security > Merge accounts." Reuse each locale's existing menu path and keep each file's quote style. - No change in
OnboardingMergingAccountBlockedVieworBaseOnboardingPurpose. Both already pass the work email to this key. - Tests:
tests/unit/AddWorkEmailTest.ts: an onboarding403 Forbiddenwith no task report sets the guidance key. An unknown error still sets no key.tests/ui/WorkEmailOnboarding.tsx: update the501blocked-merge test at line 1309 to expect the guidance copy. Add a666blocked-merge case and a regular-onboarding403case. Keep the test at line 1862 as it is. It setsisMergingAccountBlockedwith no request, so it still covers the generic fallback.
What alternative solutions did you explore? (Optional)
- Add
CONST.JSON_CODEfor501and checkjsonCode === 501. This works too, but it ties the fix to a code that the backend doesn't name, while theonyxDataflag is what drives the screen. - Add a new
existingAccountSubtitlekey. That would give one backend error two strings, so I'd reuse the existing key. - Change the generic
subtitlecopy. That fallback also covers unknown errors where the email may not belong to an existing account, so merge instructions could be wrong there.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/105015#issuecomment-6491107850) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
Triggered auto assignment to @marcaaron, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
@marcaaron Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user signs up with a phone number (or personal email) and tries to add a work email during onboarding that already has an Expensify account that cannot be automatically merged, the "We couldn't add [work email]" screen (OnboardingMergingAccountBlockedView) shows a generic "Please try again later, or continue without adding a work email" message instead of explaining how the user can merge the accounts themselves ("Sign in with [work email] and merge this account from Account > Security > Merge accounts." ).
What is the root cause of that problem?
In src/components/OnboardingMergingAccountBlockedView.tsx (lines 37–50), the component checks onboardingErrorMessageTranslationKey (ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY). When the backend returns a generic error or no specific translation key for an existing unmergeable work email account, OnboardingMergingAccountBlockedView falls back to translate('onboarding.mergeBlockScreen.subtitle', {workEmail}) (lines 48–49), which in src/languages/en.ts (line 3679) reads "We couldn't add ${workEmail}. Please try again later, or continue without adding a work email." instead of instructing the user to sign in with ${workEmail} and merge from Account > Security > Merge accounts.
What changes do you think we should make in order to solve the problem?
- In
src/languages/en.ts(and corresponding language files such assrc/languages/es.ts), updateonboarding.mergeBlockScreen.subtitle(or add the appropriate error key mapped insrc/libs/actions/Session/index.tsandsrc/components/OnboardingMergingAccountBlockedView.tsxlines 37–50) so that when adding${workEmail}is blocked during onboarding because the account already exists, the subtitle explains how to merge:"We couldn't add ${workEmail}. Sign in with ${workEmail} and merge this account from Account > Security > Merge accounts, or continue without adding a work email."(matching the exact copy specified by design). - In
src/components/OnboardingMergingAccountBlockedView.tsx, ensureworkEmailis passed into the translation interpolation so the blocked email address is rendered in both the title and instructions.
What alternative solutions did you explore? (Optional)
We considered adding a clickable link to Account > Security > Merge accounts, but because the user is currently signed into the new phone/personal account inside the onboarding modal and must first sign in with [work email], plain instructional copy in OnboardingMergingAccountBlockedView is clearer and avoids navigating away from onboarding unexpectedly.