Skip to content

Fix onboarding flow not appearing after anonymous sign-in from public room thread#85660

Merged
JS00001 merged 15 commits intomainfrom
claude-fixOnboardingAfterAnonymousSignIn
Mar 24, 2026
Merged

Fix onboarding flow not appearing after anonymous sign-in from public room thread#85660
JS00001 merged 15 commits intomainfrom
claude-fixOnboardingAfterAnonymousSignIn

Conversation

@MelvinBot
Copy link
Copy Markdown
Contributor

@MelvinBot MelvinBot commented Mar 18, 2026

Explanation of Change

When an anonymous user signs in via the SignInModal (e.g., tapping "Reply in thread" in a public room), Navigation.dismissModal() and openApp() were firing in parallel. The dismiss triggered the OnboardingGuard while IS_LOADING_APP was still true, causing the guard to skip the onboarding redirect entirely. This left new users stuck without onboarding and with an infinite loading state on the Inbox.

This PR fixes the issue by ensuring openApp(true) fully completes (so IS_LOADING_APP transitions to false and NVP_ONBOARDING is loaded) before dismissing the modal. This way, when dismissModal() triggers the OnboardingGuard, it evaluates with accurate data and properly redirects new users to onboarding.

The fix uses Promise.all to run openApp (with its queue idle waits) and Navigation.isNavigationReady() concurrently, only calling dismissModal() after both complete.

Fixed Issues

$ #83092
PROPOSAL: #83092 (comment)

Tests

  1. Open a public room link as an anonymous user (e.g., https://new.expensify.com/r/1540486774487195)
  2. Navigate to a thread
  3. Hold/tap a message to open the action menu and select "Reply in thread"
  4. Complete sign-in with a new account
  5. Verify the onboarding flow appears after sign-in
  6. Complete onboarding and verify you can navigate back to Inbox without infinite loading
  • Verify that no errors appear in the JS console

Offline tests

  1. Sign in from a public room thread reply as described above
  2. Toggle airplane mode/disconnect network after sign-in completes
  3. Verify the app doesn't hang in a loading state — it should either show onboarding or the Inbox depending on connectivity timing

QA Steps

  1. As an anonymous user, visit a public room link on iOS mWeb Safari
  2. Navigate to a thread within that room
  3. Tap on a message and select "Reply in thread"
  4. Complete sign-in with a brand new account
  5. Verify the onboarding flow appears after sign-in
  6. Complete onboarding
  7. Navigate back to Inbox and verify it loads correctly (no infinite loading/skeleton state)
  • 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
    • MacOS: Desktop
  • 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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • 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.
  • I verified that similar component doesn't exist in the codebase
  • I verified that all props are defined accurately and each prop has a /** comment above it */
  • I verified that each file is named correctly
  • I verified that each component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
  • I verified that the only data being stored in component state is data necessary for rendering and nothing else
  • In component if we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes
  • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
  • I verified that component internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
  • I verified that all JSX used for rendering exists in the render method
  • I verified that each component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

…gn-in

When an anonymous user signs in via the SignInModal (e.g. "Reply in thread"
in a public room), Navigation.dismissModal() and openApp() were firing in
parallel. The dismiss triggered the OnboardingGuard while IS_LOADING_APP was
still true, causing it to skip the onboarding redirect entirely.

Now we ensure openApp(true) fully completes (IS_LOADING_APP transitions to
false, NVP_ONBOARDING is loaded) before dismissing the modal, so the
OnboardingGuard evaluates with accurate data and properly redirects new
users to onboarding.

Co-authored-by: Eric Han <eh2077@users.noreply.github.com>
@MelvinBot MelvinBot requested a review from a team March 18, 2026 14:24
@MelvinBot
Copy link
Copy Markdown
Contributor Author

I created this PR from an upstream branch since I don't have push access to your fork.

To take ownership of this branch and be able to push updates, run:

git remote add upstream https://github.com/Expensify/App.git
git fetch upstream claude-fixOnboardingAfterAnonymousSignIn
git checkout -b claude-fixOnboardingAfterAnonymousSignIn upstream/claude-fixOnboardingAfterAnonymousSignIn
git push -u origin claude-fixOnboardingAfterAnonymousSignIn

Then you can close this PR and open a new one from your fork.

@eh2077
Copy link
Copy Markdown
Contributor

eh2077 commented Mar 20, 2026

@MelvinBot Can you add unit test to cover the change?

Tests cover:
- Anonymous users don't trigger openApp or dismissModal
- Non-anonymous users trigger openApp then dismissModal
- dismissModal waits for both openApp chain and isNavigationReady (Promise.all)
- Session transition from anonymous to authenticated triggers the correct flow

Co-authored-by: Eric Han <eh2077@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Added unit tests for the SignInModal useEffect behavior in tests/unit/SignInModalTest.tsx. The tests cover:

  1. Anonymous user — verifies openApp and dismissModal are NOT called when authTokenType is ANONYMOUS
  2. Non-anonymous user — verifies waitForIdle, openApp(true), and dismissModal are all called
  3. Promise.all ordering — verifies dismissModal waits for BOTH the openApp chain and isNavigationReady() to complete before firing (the core behavior this PR introduces)
  4. Session transition — verifies the correct flow when a session transitions from anonymous to authenticated

Co-authored-by: Eric Han <eh2077@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Fixed the failing Prettier check: ran prettier on tests/unit/SignInModalTest.tsx which reordered the SignInModal import to be grouped with the other imports at the top of the file.

- Add type-safe casts for require() calls inside jest.mock factories
- Add eslint-disable comments for __esModule naming convention
- Add file-level disable for no-non-null-assertion
- Use React.createElement instead of JSX in mock factories

Co-authored-by: Eric Han <eh2077@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Fixed the failing ESLint check in tests/unit/SignInModalTest.tsx (19 errors):

  • Added type-safe casts for require() calls inside jest.mock factories (as typeof React, as {View: typeof RNView}) to resolve no-unsafe-assignment, no-unsafe-return, no-unsafe-call, and no-unsafe-member-access errors
  • Added eslint-disable-next-line @typescript-eslint/naming-convention comments for __esModule properties
  • Added file-level eslint-disable @typescript-eslint/no-non-null-assertion for non-null assertions used after expect guards
  • Switched mock components from JSX to React.createElement to avoid needing React in scope inside factory closures

Co-authored-by: Eric Han <eh2077@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Fixed the failing checks in tests/unit/SignInModalTest.tsx:

  1. ESLint (no-unsafe-return): Replaced wrapper arrow functions with direct mock references for dismissModal and goBack to avoid returning any
  2. TypeScript (spread argument): Replaced wrapper for openApp with direct mock reference to fix tuple type mismatch
  3. TypeScript (ref on View): Removed unused ref parameter from the MockSignInPage forwardRef since the mock doesn't need to forward refs

Co-authored-by: Eric Han <eh2077@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Fixed the failing test (job 6) check: the SignInModalTest.tsx mock for @libs/Browser was missing the isSafari function, which src/styles/index.ts imports at module load time. Added isSafari: jest.fn(() => false) to the mock.

Co-authored-by: Eric Han <eh2077@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Fixed the failing test (job 6) check: the @libs/Browser mock in tests/unit/SignInModalTest.tsx was missing getBrowser (and other exports). The styles module calls getBrowser() during initialization, which caused a TypeError when the test suite loaded. Added all Browser module exports to the mock.

- Add missing `flush` export to SequentialQueue mock (Network module
  imports it during initialization)
- Mock `useSession` from OnyxListItemProvider to avoid requiring the
  full context provider tree in unit tests
- Update tests to set session data via the mock instead of Onyx.merge

Co-authored-by: Eric Han <eh2077@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Fixed the failing test (job 6) check — SignInModalTest.tsx had two issues:

  1. Missing flush in SequentialQueue mock: src/libs/Network/index.ts imports {flush} from SequentialQueue at module init time, but the test only mocked waitForIdle. Added flush: jest.fn() to the mock.

  2. Missing useSession context provider: SignInModal calls useSession() from OnyxListItemProvider, which requires a SessionProvider ancestor. Added a mock for @components/OnyxListItemProvider that provides useSession directly, and updated tests to set session data via the mock.

Co-authored-by: Eric Han <eh2077@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Fixed the failing test (job 6) check. The SignInModalTest.tsx mock for openApp was directly assigning mockOpenApp in the jest.mock factory, but due to Jest's hoisting behavior, mockOpenApp was undefined when the factory executed. Changed to a wrapper function (...args) => mockOpenApp(...args) to defer the lookup — the same pattern already used for waitForIdle in the same test file.

The inline mock factory for @libs/actions/App was not properly overriding
the manual __mocks__/App.ts mock. Switch to defining jest.fn() directly in
the factory and importing from the mocked module, matching the pattern used
by other tests (e.g. useConfirmReadyToOpenApp.test.ts).

Co-authored-by: Eric Han <eh2077@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Fixed the failing test (job 6) check: the SignInModalTest.tsx mock for @libs/actions/App was using a closure over an external variable (mockOpenApp) in the mock factory, which was being interfered with by the manual __mocks__/App.ts mock. Switched to defining jest.fn() directly in the factory and importing openApp from the mocked module, matching the pattern used by other tests like useConfirmReadyToOpenApp.test.ts.

Co-authored-by: Eric Han <eh2077@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Fixed the failing test in SignInModalTest.tsx. The issue was a Jest mock hoisting problem: mockDismissModal and mockGoBack were captured by value in the jest.mock factory, but at factory execution time (triggered by imports), those const variables hadn't been assigned yet — so they were undefined.

Changed the mock to use wrapper functions ((...args) => mockDismissModal(...args)) that read the variable at call time instead of at factory creation time, matching the pattern already used for isNavigationReady.

Remove __esModule/default wrapper from Navigation mock (matching all
other test files) and use block bodies to avoid returning any values
that trigger no-unsafe-return ESLint errors.

Co-authored-by: Eric Han <eh2077@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Fixed the failing checks:

  1. ESLint no-unsafe-return: The Navigation mock wrapper functions were implicitly returning any from jest.fn() calls. Changed to block bodies to avoid the unsafe return.

  2. Jest test failures (Navigation.dismissModal is not a function): The Navigation mock used __esModule: true with a default wrapper, which doesn't match how other tests in this codebase mock Navigation. Simplified the mock to put functions directly on the mock object (matching the pattern in PromotedActionsBarTest, useSubPageTest, etc.), which allows Babel's _interopRequireDefault to correctly resolve the default import.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

The failing checks are:

  1. checklist — This is the PR Author Checklist check, which is expected/informational.

  2. perf-tests — This failure is unrelated to this PR. The error is:

    Render count difference exceeded the allowed deviation of 0. Current difference: 0.8

    It's failing on useAdvancedSearchFilters hook initial render with policies, which has nothing to do with the files changed in this PR (SignInModal.tsx and SignInModalTest.tsx). This appears to be a flaky perf test.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2026

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/pages/signin/SignInModal.tsx 88.88% <ø> (+88.88%) ⬆️
... and 9 files with indirect coverage changes

@melvin-bot melvin-bot bot requested a review from JS00001 March 24, 2026 12:46
@JS00001
Copy link
Copy Markdown
Contributor

JS00001 commented Mar 24, 2026

Rerunning the tests

@MelvinBot
Copy link
Copy Markdown
Contributor Author

The failing checks are unrelated to this PR's changes.

perf-tests failure: The test [SelectionList] should scroll and select a few items reports a render count difference of 2 (allowed deviation: 0). This PR only modifies src/pages/signin/SignInModal.tsx and tests/unit/SignInModalTest.tsx — neither of which is related to SelectionList rendering. This appears to be a pre-existing or flaky perf regression.

checklist failure: This is the PR Author/Reviewer Checklist check, which is unrelated to code.

@JS00001
Copy link
Copy Markdown
Contributor

JS00001 commented Mar 24, 2026

@eh2077 can you pull main

@eh2077
Copy link
Copy Markdown
Contributor

eh2077 commented Mar 24, 2026

@MelvinBot Can you merge with main branch? If not, then I can help

…fterAnonymousSignIn

Co-authored-by: Eric Han <eh2077@users.noreply.github.com>
@MelvinBot
Copy link
Copy Markdown
Contributor Author

Merged main into this branch — no conflicts.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

The only non-checklist failing check is Reassure Performance Tests, which is failing due to a [SelectionList] should scroll and select a few items render count regression (5 → 7 renders, +2).

This is unrelated to this PR's changes. This PR only modifies SignInModal.tsx and SignInModalTest.tsx, which have no connection to SelectionList rendering. The same perf test is also failing on other unrelated branches (e.g. feat/last-12-months-preset, @GCyganek/unlock-landscape-mode), confirming this is a pre-existing/flaky issue on main.

The latest checks (after the merge with main) are currently still in progress — all completed checks so far are passing.

@MelvinBot
Copy link
Copy Markdown
Contributor Author

The failing test (job 6) check is unrelated to this PR — it's a CI infrastructure issue.

Analysis: The job had zero steps and timed out at exactly 10 minutes, meaning the runner never allocated or initialized. This is a transient CI runner problem, not a code failure.

Evidence: This PR only modifies src/pages/signin/SignInModal.tsx and tests/unit/SignInModalTest.tsx. The job never got far enough to run any tests.

The other failing check (checklist) is the PR Author Checklist, which is unrelated to code.

Recommendation: Re-run the failed test (job 6) job to resolve this.

@JS00001 JS00001 merged commit ae06156 into main Mar 24, 2026
45 of 48 checks passed
@JS00001 JS00001 deleted the claude-fixOnboardingAfterAnonymousSignIn branch March 24, 2026 14:56
@github-actions
Copy link
Copy Markdown
Contributor

🚧 @JS00001 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/JS00001 in version: 9.3.44-0 🚀

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

Bundle Size Analysis (Sentry):

@OSBotify
Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/JS00001 in version: 9.3.47-0 🚀

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

Bundle Size Analysis (Sentry):

@izarutskaya
Copy link
Copy Markdown

@eh2077 For some reason public room didn't display after sign in
mWeb/Safari
Build 9.3.48-1

Screenrecording.03-26-2026.4-59-29.Am.1.mp4

@eh2077
Copy link
Copy Markdown
Contributor

eh2077 commented Mar 26, 2026

Hmm, it worked for me when testing #85660 (comment)

@eh2077
Copy link
Copy Markdown
Contributor

eh2077 commented Mar 26, 2026

@izarutskaya Are you able to reproduce it consistently?

@izarutskaya
Copy link
Copy Markdown

izarutskaya commented Mar 26, 2026

Another tester also cann't see room after sign in

1774496144497.retest.mp4

@bernhardoj
Copy link
Copy Markdown
Contributor

This also caused the sign-in modal not to close

web.mp4

@eh2077
Copy link
Copy Markdown
Contributor

eh2077 commented Mar 26, 2026

Thanks for your comments, going to revert it to unblock issues.

JS00001 pushed a commit that referenced this pull request Mar 26, 2026
…AfterAnonymousSignIn"

This reverts commit ae06156, reversing
changes made to 064cafd.
@OSBotify
Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.3.48-2 🚀

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

@OSBotify
Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/JS00001 in version: 9.3.49-0 🚀

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

Bundle Size Analysis (Sentry):

@OSBotify
Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.3.49-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