Skip to content

add descriptive error message for work email already associated with 2FA account#88287

Merged
grgia merged 21 commits into
Expensify:mainfrom
mnshrm:fix/add-descriptive-2FA-error-message
May 22, 2026
Merged

add descriptive error message for work email already associated with 2FA account#88287
grgia merged 21 commits into
Expensify:mainfrom
mnshrm:fix/add-descriptive-2FA-error-message

Conversation

@mnshrm
Copy link
Copy Markdown

@mnshrm mnshrm commented Apr 19, 2026

Explanation of Change

This MR resolves error reporting in case '2FA account error' that occurs when user tries to add a work email which is already associated with an account with 2FA enabled.
MR adds new onyx key onboardingErrorMessage, uses makeRequestWithSideEffect so that key is updated, then with the use of useEffect hook, uses newly created actions addWorkEmailFormError, clearWorkEmailFormError, to update the form errors, this allows rendering of 2FA error on screen as an inline error. Next, as soon as user tries to correct his/her form errors are cleared when form input value changes.

Fixed Issues

$ #86194
PROPOSAL: $ #86194 (comment)

Tests

PRE-REQUISITE: A account with work email and 2FA enabled.

  1. Scenario : 2FA error is displayed when user attempts to enter a work email already associated to a account with 2FA enabled

    1. Navigate to new expensify
    2. Enter a new email id, and click on continue button.
    3. Click on join button
    4. Wait for new onboarding flow popup.
    5. On 'what's your work email' popup, enter a work email already associated with an account with 2FA enabled.
    6. Click on add work email button.
    7. Error should be displayed with message ' is a login for an Expensify account with Two-Factor Authentication (2FA) enabled.'
  2. Scenario: 2FA error is not visible when user modifies input value of work email form.

    1. Navigate to new expensify
    2. Enter a new email id, and click on continue button.
    3. Click on join button
    4. Wait for new onboarding flow popup.
    5. On 'what's your work email' popup, enter a work email already associated with an account with 2FA enabled.
    6. Click on add work email button.
    7. Error should be displayed with message ' is a login for an Expensify account with Two-Factor Authentication (2FA) enabled.'
    8. user attempts to correct mistake, by modifying work email input.
    9. Error should be removed and not be displayed as soon as input value changes.
  3. Scenario: User is able to add work email if he/she enters a work email without any associated account.

    1. Navigate to new expensify
    2. Enter a new email id, and click on continue button.
    3. Click on join button
    4. Wait for new onboarding flow popup.
    5. On 'what's your work email' popup, enter a work email already associated with an account with 2FA enabled.
    6. Click on add work email button.
    7. Error should be displayed with message ' is a login for an Expensify account with Two-Factor Authentication (2FA) enabled.'
    8. user attempts to correct mistake, by modifying work email input.
    9. Error should be removed and not be displayed as soon as input value changes.
    10. User enters a new work email not associated to any account
    11. User clicks on add work email button
    12. User enters OTP received on work email
    13. User gets success message on submitting correct OTP

We do get following error in console.

installHook.js:1 In HTML, <button> cannot be a descendant of <button>.
This will cause a hydration error.

This error also appears in main branch as well, so it is not due to our code changes.

  • Verify that no errors appear in the JS console

Offline tests

PRE-REQUISITE: A account with work email and 2FA enabled.

  1. Scenario: Verify offline error for 'what's your work email' form
    1. Navigate to new expensify
    2. Enter a new email id, and click on continue button.
    3. Click on join button
    4. Wait for new onboarding flow popup.
    5. On 'what's your work email' popup, enter a work email already associated with an account with 2FA enabled.
    6. Click on add work email button.
    7. Error 'We couldn’t add your work email as you appear to be offline' is displayed

QA Steps

Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native Android Android offline
Android: mWeb Chrome Android-16 0 Android-16 0 (1)
iOS: Native Screenshot from 2026-05-06 02-13-38 Screenshot from 2026-05-06 02-38-33
iOS: mWeb Safari ios-26 2 ios-26 2 (1)
MacOS: Chrome macOS-Tahoe macOS-Tahoe (1)
Windows: Chrome Windows-11 Windows-11 (1)

@mnshrm mnshrm force-pushed the fix/add-descriptive-2FA-error-message branch from b425d5d to d89d54e Compare April 24, 2026 11:18
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@mnshrm
Copy link
Copy Markdown
Author

mnshrm commented Apr 24, 2026

I have read the CLA Document and I hereby sign the CLA

@mnshrm mnshrm marked this pull request as ready for review April 26, 2026 17:47
@mnshrm mnshrm requested review from a team as code owners April 26, 2026 17:47
@melvin-bot melvin-bot Bot requested review from a team, eh2077 and joekaufmanexpensify and removed request for a team April 26, 2026 17:47
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented Apr 26, 2026

@eh2077 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot Bot requested review from JmillsExpensify and removed request for a team April 26, 2026 17:47
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4951e322fe

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/pages/OnboardingWorkEmail/BaseOnboardingWorkEmail.tsx
@JmillsExpensify
Copy link
Copy Markdown
Contributor

Aren't we missing screenshots for the other platforms?

Then this is more of an internal comment, though I think we can really tighten up the error message, as it's hard to understand. I recommend: "This login is an existing account with Two-Factor Authentication (2FA) enabled." The offline error message looks fine.

@mnshrm
Copy link
Copy Markdown
Author

mnshrm commented Apr 27, 2026

Thanks @JmillsExpensify for review, yes I am currently trying to test on all platforms, that's why screenshots are missing.
@eh2077, given @JmillsExpensify's inputs regarding error message, if it is fine from your end as well, I will move onto include this change in PR. Please provide your views on it

@eh2077
Copy link
Copy Markdown
Contributor

eh2077 commented Apr 28, 2026

@mnshrm yeah, let's update the error message as suggested and let me know once you tested all platforms, thanks!

@joekaufmanexpensify joekaufmanexpensify removed their request for review April 28, 2026 21:41
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented Apr 30, 2026

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx ts-node ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx ts-node ./scripts/generateTranslations.ts --compare-ref main

@mnshrm
Copy link
Copy Markdown
Author

mnshrm commented May 19, 2026

@grgia, fixed lint errors

@eh2077
Copy link
Copy Markdown
Contributor

eh2077 commented May 21, 2026

@mnshrm Please have a look at the conflicts, thx!

grgia
grgia previously approved these changes May 21, 2026
@grgia grgia self-requested a review May 21, 2026 15:33
@mnshrm
Copy link
Copy Markdown
Author

mnshrm commented May 21, 2026

There are some errors in jobs, fixing them.

@mnshrm
Copy link
Copy Markdown
Author

mnshrm commented May 21, 2026

Fixed errors

@grgia grgia merged commit 698fa83 into Expensify:main May 22, 2026
36 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🚧 @grgia has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify
Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/grgia in version: 9.3.80-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@MelvinBot
Copy link
Copy Markdown
Contributor

No help site changes are required for this PR.

This PR adds an inline error message during the onboarding work email step when a user enters an email already associated with a 2FA-enabled account. It's a UI error handling improvement (descriptive inline error instead of a generic blocking screen) — no new feature, workflow, or setting was introduced.

The existing help site articles covering Two-Factor Authentication, Login Troubleshooting, and Join Your Company's Workspace don't document specific onboarding error messages, so no updates are needed.

@jponikarchuk
Copy link
Copy Markdown

This PR failing because of the issue #91566
This issue is reproducible in: All platforms

@mnshrm
Copy link
Copy Markdown
Author

mnshrm commented May 25, 2026

@jponikarchuk, Allow me to investigate this issue and provide an update in 91566

Thanks

@mnshrm
Copy link
Copy Markdown
Author

mnshrm commented May 25, 2026

@jponikarchuk, Here are my findings, I think bug logged is not correct.
The recently logged bug is incorrect, as the precondition for test case was not met. Applause email id used is not configured correctly, as we are getting this error in response.

Image

which is different from what is expected,

Image

According to logic written, 2FA error is only rendered when above mentioned error message is returned in response, otherwise generic message is surfaced.

@OSBotify
Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/luacmartins in version: 9.3.81-2 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants