App icon indicating copy to clipboard operation
App copied to clipboard

[$175] Onboarding - Explain how to merge when "We couldn't add [work email]" blocks the user

Open melvin-bot[bot] opened this issue 1 month ago • 29 comments

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
Issue OwnerCurrent Issue Owner: @marcaaron

melvin-bot[bot] avatar Oct 26 '26 14:10 melvin-bot[bot]

Triggered auto assignment to Contributor-plus team member for initial proposal review - @dmkt9 (External)

melvin-bot[bot] avatar Oct 26 '26 14:10 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022114731663671120637

melvin-bot[bot] avatar Oct 26 '26 14:10 melvin-bot[bot]

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:
    1. Unnecessary Component Mutations: Refactoring component logic increases blast radius and introduces rendering side-effects.
    2. Placeholder Mismatches: Using named placeholders like {workEmail} or %{email} breaks Expensify's Localize.translate parameter interpolation, which expects positional index tokens (i.e., {0}).
    3. Locale Incompleteness: Failing to update es.ts alongside en.ts causes 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

camesenin avatar Oct 26 '26 14:10 camesenin

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Oct 26 '26 14:10 melvin-bot[bot]

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?

  1. New translation key. Add onboarding.mergeBlockScreen.existingAccountSubtitle next to the other mergeBlockScreen subtitles in src/languages/en.ts, with the same (workEmail: string | undefined) signature as domainControlledSubtitle:

    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 from validatedPublicDomainSubtitle so 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.ts and the Polyglot Parrot diff, reviewed by hand.

  2. Set the key for the existing-account rejection in every onboarding flow (AddWorkEmail, src/libs/actions/Session/index.ts). Drop the addWorkEmailTaskReport && 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 !isOnboardingFlow early return, and is not added to the errorTranslationKey chain. On the workspace company-card / Expensify Card forms (#98664), the same 403 must keep showing common.genericErrorMessage inline, not onboarding merge instructions. The new key replaces validatedPublicDomainSubtitle, 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.

  3. Merge step failures (MergeIntoAccountAndLogin, same file). In the else branch that blocks the merge, also write ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY = 'onboarding.mergeBlockScreen.existingAccountSubtitle'. If the message contains CONST.MERGE_ACCOUNT_2FA_ERROR or CONST.MERGE_ACCOUNT_SINGLE_SIGN_ON_ERROR, use the existing onboarding.workEmail2FAError / onboarding.singleSignOnError keys instead, the same mapping AddWorkEmail already uses. Signing in to the work account and merging from Security is the right recovery for any failure at this point.

  4. Let the view and the purpose screen pass the email to the new key. In OnboardingMergingAccountBlockedView.getErrorSubtitle and BaseOnboardingPurpose.getErrorMessage, the email-interpolated keys are compared one by one. Add existingAccountSubtitle to that branch, using a small shared list (for example MERGE_BLOCK_SUBTITLE_KEYS_WITH_EMAIL in CONST or 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.subtitle stays 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: a 403 Forbidden response with no task report sets isMergingAccountBlocked: true and ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY = 'onboarding.mergeBlockScreen.existingAccountSubtitle'.
  • Same file: an unknown error (for example 500) still sets only isMergingAccountBlocked, so the generic subtitle remains the fallback.
  • Same file, workspace card flow: the 403 still shows common.genericErrorMessage inline and writes no onboarding state (the existing test keeps passing).
  • MergeIntoAccountAndLogin: a non-invalid-code error sets the new key; an invalid code still sets contacts.genericFailureMessages.validateSecondaryLogin and 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 validatedPublicDomainSubtitle for 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 bare 403 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.

xomaxie avatar Oct 26 '26 14:10 xomaxie

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:

  1. Validated personal-email / phone-number login in standard onboarding (AddWorkEmail in src/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 with CONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR ('403 Forbidden'). Because Session/index.ts gates validatedPublicDomainSubtitle behind if (addWorkEmailTaskReport && response?.message === CONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR), standard onboarding (where addWorkEmailTaskReport is undefined) only sets Onyx.merge(ONYXKEYS.NVP_ONBOARDING, {isMergingAccountBlocked: true}) with no error translation key.
  2. Account merge blocked during MergeIntoAccountAndLogin (src/libs/actions/Session/index.ts and tests/ui/WorkEmailOnboarding.tsx): When an unvalidated user enters a work email belonging to an existing account (shouldValidate: true) and submits the validation code to MergeIntoAccountAndLogin, the backend blocks non-mergeable accounts either by returning isMergingAccountBlocked: true in onyxData (e.g., jsonCode: 501 in MergeIntoAccountAndLoginBlockMerge at tests/ui/WorkEmailOnboarding.tsx#L150-L166) or via the else branch of response?.jsonCode === CONST.JSON_CODE.EXP_ERROR (666). In both cases, ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY was cleared to null in optimisticData, so OnboardingMergingAccountBlockedView renders onboarding.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:

  1. src/languages/en.ts
subtitle: (workEmail: string | undefined) => `Sign in with ${workEmail} and merge this account from Account > Security > Merge accounts.`,
  1. 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.`,
  1. src/languages/el.ts
subtitle: (workEmail: string | undefined) =>
    `Συνδεθείτε με το ${workEmail} και συγχωνεύστε αυτόν τον λογαριασμό από Λογαριασμός > Ασφάλεια > Συγχώνευση λογαριασμών.`,
  1. src/languages/es.ts
subtitle: (workEmail: string | undefined) => `Inicia sesión con ${workEmail} y fusiona esta cuenta desde Cuenta > Seguridad > Fusionar cuentas.`,
  1. src/languages/fr.ts
subtitle: (workEmail: string | undefined) =>
    `Connectez-vous avec ${workEmail} et fusionnez ce compte depuis Compte > Sécurité > Fusionner les comptes.`,
  1. src/languages/it.ts
subtitle: (workEmail: string | undefined) =>
    `Accedi con ${workEmail} e unisci questo account da Account > Sicurezza > Unisci account.`,
  1. src/languages/ja.ts (matching securityPage.mergeAccount 'アカウントを統合')
subtitle: (workEmail: string | undefined) =>
    `${workEmail} でサインインし、「アカウント」>「セキュリティ」>「アカウントを統合」からこのアカウントを統合してください。`,
  1. src/languages/nl.ts
subtitle: (workEmail: string | undefined) => `Log in met ${workEmail} en voeg dit account samen via Account > Beveiliging > Accounts samenvoegen.`,
  1. src/languages/pl.ts (matching common.security 'Bezpieczeństwo' and securityPage.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.`,
  1. src/languages/pt-BR.ts
subtitle: (workEmail: string | undefined) =>
    `Entre com ${workEmail} e mescle esta conta em Conta > Segurança > Mesclar contas.`,
  1. src/languages/zh-hans.ts
subtitle: (workEmail: string | undefined) => `请使用 ${workEmail} 登录,并从“账户 > 安全 > 合并账户”合并此账户。`,
  1. Automated Tests (tests/ui/WorkEmailOnboarding.tsx)
  • Existing test 'should display onboarding merge block screen content correctly' in tests/ui/WorkEmailOnboarding.tsx (L1287-L1314) already asserts expect(screen.getByText(TestHelper.translateLocal('onboarding.mergeBlockScreen.subtitle', workEmail))).toBeOnTheScreen() after MergeIntoAccountAndLoginBlockMerge().
  • Add an explicit test verifying that when AddWorkEmail is rejected with 403 Forbidden during standard onboarding (without a Concierge task report), OnboardingMergingAccountBlockedView renders the updated onboarding.mergeBlockScreen.subtitle interpolated with workEmail.

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.subtitle directly matches the issue specification verbatim ("This is the fallback subtitle, onboarding.mergeBlockScreen.subtitle, in src/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 both AddWorkEmail (403 Forbidden) and MergeIntoAccountAndLogin (501 via onyxData and 666), and avoids writing an email-parameterized key to ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY.
  • If we instead want unknown AddWorkEmail 666 errors (e.g., 500) to retain the generic fallback while existing-account blocks show the merge instructions via onboarding.mergeBlockScreen.existingAccountSubtitle, three things must be handled together so no path breaks:
    1. In AddWorkEmail (src/libs/actions/Session/index.ts#L1790), set ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY to 'onboarding.mergeBlockScreen.existingAccountSubtitle' whenever response?.message === CONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR (removing the addWorkEmailTaskReport && gate).
    2. In MergeIntoAccountAndLogin (src/libs/actions/Session/index.ts#L1858-L1873), set 'onboarding.mergeBlockScreen.existingAccountSubtitle' both in the response?.jsonCode === CONST.JSON_CODE.EXP_ERROR (666) non-invalid-code branch and when onboardingUpdate?.value sets isMergingAccountBlocked: true (such as jsonCode: 501 in MergeIntoAccountAndLoginBlockMerge at tests/ui/WorkEmailOnboarding.tsx#L150-L166, which bypasses the jsonCode === 666 branch).
    3. In src/pages/OnboardingWorkEmail/BaseOnboardingWorkEmail.tsx#L282-L291, pass workEmail (or skip mergeBlockScreen keys) when calling addWorkEmailFormError(translate(workEmailErrorTranslationKey, workEmail)), because calling translate(workEmailErrorTranslationKey) without workEmail interpolates "undefined" into the form error state.

shilo1979jk avatar Oct 26 '26 15:10 shilo1979jk

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');
}
  1. ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY is only set to 'onboarding.mergeBlockScreen.validatedPublicDomainSubtitle' when addWorkEmailTaskReport is defined (i.e. task-based Concierge flow). In standard onboarding, addWorkEmailTaskReport is undefined.
  2. As a result, standard onboarding sets isMergingAccountBlocked: true without setting ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY.
  3. In src/components/OnboardingMergingAccountBlockedView.tsx (lines 48–49), getErrorSubtitle falls back to onboarding.mergeBlockScreen.subtitle:
    // Fallback to generic error message
    return translate('onboarding.mergeBlockScreen.subtitle', workEmail);
    
  4. Additionally, validatedPublicDomainSubtitle in src/languages/en.ts still 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?

  1. In src/libs/actions/Session/index.ts: Remove the addWorkEmailTaskReport && condition so that any CONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR during 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');
             }
    
  2. Update validatedPublicDomainSubtitle across all 11 supported locales in src/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

bhomvratrai-glitch avatar Oct 26 '26 17:10 bhomvratrai-glitch

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?

  1. 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).
  2. 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.
  3. Add the branch in getErrorSubtitle in OnboardingMergingAccountBlockedView.tsx, passing workEmail, so the specific message renders only for this failure.
  4. 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.

khizzcr7 avatar Oct 26 '26 18:10 khizzcr7

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?

  1. Add new localized translation keys: In src/languages/en.ts (and src/languages/es.ts):
onboarding: {
    mergeBlockScreen: {
        ...
        existingAccountSubtitle: 'Sign in with {0} and merge this account from Account > Security > Merge accounts.',
    },
},
  1. Set the specific translation key on merge conflict: In src/libs/actions/Session/index.ts inside 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');
  1. Handle interpolation in the blocked view: In src/components/OnboardingMergingAccountBlockedView.tsx, inside getErrorSubtitle: Ensure the new key interpolates workEmail:
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:

  1. Sign up for a new account using a phone number or personal email.
  2. In the onboarding flow, proceed to the step prompting to add a work email.
  3. Enter an email address that already belongs to an existing Expensify account.
  4. Verify the blocked view title and subtitle clearly state: "Sign in with [work email] and merge this account from Account > Security > Merge accounts."
  5. Verify the email placeholder {0} correctly displays the entered work email.
  6. Switch application language to Spanish and confirm the localized subtitle renders correctly.

Enes2553 avatar Oct 26 '26 19:10 Enes2553

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?

  1. In src/libs/actions/Session/index.ts (AddWorkEmail, lines 1785–1794), specific translation keys for ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY are only merged when response?.message equals CONST.WORK_DOMAIN_CONTROLLED_ERROR or CONST.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), errorTranslationKey is undefined, and ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY is not updated before setting isMergingAccountBlocked: true.
  2. In src/components/OnboardingMergingAccountBlockedView.tsx (getErrorSubtitle, lines 37–50), because onboardingErrorMessage is 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?

  1. Locale updates: In src/languages/en.ts and src/languages/es.ts under onboarding.mergeBlockScreen, add existingAccountSubtitle:

    • 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).*
  2. Session action update: In src/libs/actions/Session/index.ts (AddWorkEmail error handling, lines 1785–1794): When response?.jsonCode === CONST.JSON_CODE.EXP_ERROR during onboarding and the response indicates the email belongs to an existing account (or as the default blocking subtitle when adding an existing work email), set ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY to 'onboarding.mergeBlockScreen.existingAccountSubtitle' (or 'onboarding.mergeBlockScreen.validatedPublicDomainSubtitle').

  3. Blocked view subtitle interpolation: In src/components/OnboardingMergingAccountBlockedView.tsx (getErrorSubtitle, lines 37–44): Handle existingAccountSubtitle alongside validatedPublicDomainSubtitle and domainControlledSubtitle to interpolate workEmail via translate(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

  1. Sign up with a personal email or phone number.
  2. In the onboarding flow, proceed to the step prompting to add a work email.
  3. Enter a work email that already has an Expensify account.
  4. 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.
  5. Verify the Spanish translation displays accurately when the app language is switched to Spanish.
  6. Verify unit tests in tests/unit/AddWorkEmailTest.ts pass and add a test case verifying ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY is set on existing account merge rejection.

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~016c1aa34b51059d42

bhomvratrai-glitch avatar Oct 27 '26 01:10 bhomvratrai-glitch

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Oct 27 '26 01:10 melvin-bot[bot]

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:

  1. 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 returns CONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR ('403 Forbidden'). Because setting validatedPublicDomainSubtitle is gated behind if (addWorkEmailTaskReport && response?.message === CONST.WORK_EMAIL_VALIDATED_PUBLIC_DOMAIN_ERROR), standard onboarding (where addWorkEmailTaskReport is undefined) only writes Onyx.merge(ONYXKEYS.NVP_ONBOARDING, {isMergingAccountBlocked: true}).
  2. Blocked merge during MergeIntoAccountAndLogin (src/libs/actions/Session/index.ts, lines 1858–1866): When MergeIntoAccountAndLogin blocks merging into the existing work account (isMergingAccountBlocked: true via onyxData or jsonCode === 666), ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY was cleared to null in optimisticData, so OnboardingMergingAccountBlockedView renders onboarding.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:

  1. 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.`,
  1. 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.`,
  1. src/languages/el.ts (line 3586)
// Before
subtitle: (workEmail: string | undefined) => `Δεν ήταν δυνατή η προσθήκη του ${workEmail}. Δοκιμάστε ξανά αργότερα στις ρυθμίσεις ή συνομιλήστε με το Concierge για καθοδήγηση.`,

// After
subtitle: (workEmail: string | undefined) =>
    `Συνδεθείτε με το ${workEmail} και συγχωνεύστε αυτόν τον λογαριασμό από Λογαριασμός > Ασφάλεια > Συγχώνευση λογαριασμών.`,
  1. 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.`,
  1. 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.`,
  1. 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.`,
  1. src/languages/ja.ts (lines 3493–3494)
// Before
subtitle: (workEmail: string | undefined) =>
    `${workEmail} を追加できませんでした。後で「設定」からもう一度お試しいただくか、ガイダンスについて Concierge にチャットでお問い合わせください。`,

// After
subtitle: (workEmail: string | undefined) =>
    `${workEmail} でサインインし、「アカウント」>「セキュリティ」>「アカウントを統合」からこのアカウントを統合してください。`,
  1. 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.`,
  1. 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.`,
  1. 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.`,
  1. 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.

weaieverything avatar Oct 27 '26 04:10 weaieverything

@MelvinBot submit a proposal

dmkt9 avatar Oct 27 '26 14:10 dmkt9

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

What changes do you think we should make in order to solve the problem?

  1. In AddWorkEmail, remove the addWorkEmailTaskReport && condition. Every onboarding 403 Forbidden response then sets onboarding.mergeBlockScreen.validatedPublicDomainSubtitle. Keep the check below the !isOnboardingFlow return, so the workspace card forms still show their inline generic error.
  2. In MergeIntoAccountAndLogin, when the error is not an invalid code, also set an error key before blocking. Use onboarding.workEmail2FAError or onboarding.singleSignOnError when the message matches those errors, the same way AddWorkEmail does. Otherwise use validatedPublicDomainSubtitle. At this point the user has proven they own the existing work account, so the merge guidance applies.
  3. Change the validatedPublicDomainSubtitle copy 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.
  4. No change is needed in OnboardingMergingAccountBlockedView or BaseOnboardingPurpose. Both already pass the work email to this key.
  5. Tests:
    • tests/unit/AddWorkEmailTest.ts: an onboarding 403 Forbidden with 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 existingAccountSubtitle key. This leaves two strings for the same backend error, so I'd reuse the existing key.
  • Change the generic subtitle copy. 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 avatar Oct 27 '26 14:10 MelvinBot

@MelvinBot handle the jsonCode: 501 case as well

dmkt9 avatar Oct 29 '26 07:10 dmkt9

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:

  1. AddWorkEmail returns 403 Forbidden. The guidance key is only set when there is a Concierge task report. Regular onboarding passes no task report.
  2. MergeIntoAccountAndLogin returns jsonCode: 666 with an error other than a wrong code. That branch sets isMergingAccountBlocked but no error key.
  3. MergeIntoAccountAndLogin returns jsonCode: 501. The backend blocks the merge by sending isMergingAccountBlocked: true in onyxData. The .then handler only checks for 666, so a 501 falls through to the success path. There it finds no authToken, returns didMerge: false, and never sets an error key.
Code references

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?

  1. AddWorkEmail: remove the addWorkEmailTaskReport && condition, so every onboarding 403 Forbidden sets onboarding.mergeBlockScreen.validatedPublicDomainSubtitle. Keep it below the !isOnboardingFlow return, so the workspace card forms still show their inline generic error.
  2. MergeIntoAccountAndLogin: add a small helper that picks the error key from the response message. It returns onboarding.workEmail2FAError or onboarding.singleSignOnError when the message matches, like AddWorkEmail does. Otherwise it returns validatedPublicDomainSubtitle. Use it in two places:
    • 666, not a wrong code: set the key before setting isMergingAccountBlocked.
    • 501: after reading onboardingUpdate, check whether its value has isMergingAccountBlocked: true. If so, set the key and return {didMerge: false, shouldRedirectToClassicAfterMerge: false, conciergeReportID: undefined} early, skipping the authToken path. Check the onyxData flag rather than the raw 501, because the flag is what shows the blocked screen. CONST.JSON_CODE also has no 501 entry.
  3. Copy: change validatedPublicDomainSubtitle 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 and keep each file's quote style.
  4. No change in OnboardingMergingAccountBlockedView or BaseOnboardingPurpose. Both already pass the work email to this key.
  5. Tests:
    • tests/unit/AddWorkEmailTest.ts: an onboarding 403 Forbidden with no task report sets the guidance key. An unknown error still sets no key.
    • tests/ui/WorkEmailOnboarding.tsx: update the 501 blocked-merge test at line 1309 to expect the guidance copy. Add a 666 blocked-merge case and a regular-onboarding 403 case. Keep the test at line 1862 as it is. It sets isMergingAccountBlocked with no request, so it still covers the generic fallback.

What alternative solutions did you explore? (Optional)

  • Add CONST.JSON_CODE for 501 and check jsonCode === 501. This works too, but it ties the fix to a code that the backend doesn't name, while the onyxData flag is what drives the screen.
  • Add a new existingAccountSubtitle key. That would give one backend error two strings, so I'd reuse the existing key.
  • Change the generic subtitle copy. 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.

MelvinBot avatar Oct 29 '26 07:10 MelvinBot

MelvinBot's proposal looks good to me

🎀 👀 🎀 C+

dmkt9 avatar Nov 02 '26 09:11 dmkt9

Triggered auto assignment to @marcaaron, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

melvin-bot[bot] avatar Nov 02 '26 09:11 melvin-bot[bot]

@marcaaron Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

melvin-bot[bot] avatar Nov 05 '26 21:11 melvin-bot[bot]

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?

  1. In src/languages/en.ts (and corresponding language files such as src/languages/es.ts), update onboarding.mergeBlockScreen.subtitle (or add the appropriate error key mapped in src/libs/actions/Session/index.ts and src/components/OnboardingMergingAccountBlockedView.tsx lines 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).
  2. In src/components/OnboardingMergingAccountBlockedView.tsx, ensure workEmail is 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.

jeffrey-graham avatar Nov 07 '26 06:11 jeffrey-graham