Skip to content

Block migrated user welcome modal in copilot access - #102124

Merged
mountiny merged 4 commits into
Expensify:mainfrom
callstack-internal:VickyStash/bugfix/101940-block-MigratedUserWelcomeModal-in-copilot
Sep 24, 2026
Merged

mountiny merged 4 commits into
Expensify:mainfrom
callstack-internal:VickyStash/bugfix/101940-block-MigratedUserWelcomeModal-in-copilot

Conversation

@VickyStash

@VickyStash VickyStash commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

This PR prevents MigratedUserWelcomeModal from being displayed in the co-pilot (delegated) account.

Fixed Issues

$ #101940
PROPOSAL: N/A

Tests

  • Verify that no errors appear in the JS console

Setup:

  • Account B has been added to the nudge migration and has not dismissed the migrated user welcome modal
  • Account A has copilot access to Account B
  1. Sign in as Account A
  2. Go to Settings and switch to Account B
  3. See Account B is successfully opened, no Not found page is displayed.

Offline tests

N/A

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • Verify that no errors appear in the JS console

Same, as in Tests section

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 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 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)
  • 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)
  • 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.
  • 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

MacOS: Chrome / Safari
copilot.mp4

@VickyStash

Copy link
Copy Markdown
Contributor Author

@MelvinBot review

@VickyStash
VickyStash marked this pull request as ready for review September 24, 2026 07:32
@VickyStash
VickyStash requested review from a team as code owners September 24, 2026 07:32
@melvin-bot
melvin-bot Bot requested review from garrettmknight and suneox and removed request for a team September 24, 2026 07:33
@melvin-bot

melvin-bot Bot commented Sep 24, 2026

Copy link
Copy Markdown

@suneox 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 removed the request for review from a team September 24, 2026 07:33
@MelvinBot

Copy link
Copy Markdown
Contributor

The fix is correct and lands in the right place. Three things I'd change before merge — one is a follow-up scope question, not a blocker.

Timing checks out. Delegate.ts:233 sets authTokenType = DELEGATE before clearOnyxForDelegateTransition() and openApp(), so session.authTokenType is already delegate by the time isLoadingApp flips false and the proactive navigation runs. Both entry points (proactive + evaluate) are covered.


1. Use a selector instead of importing from @userActions/Session

guards/index.ts:3 and MigratedUserWelcomeModalGuard.ts:6 pull in @userActions/Session for a one-line pure predicate (Session/index.ts:352-354).

Both guard modules are eagerly loaded from RootStackRouter.ts:1, and @userActions/Session imports @libs/Navigation/Navigation, @userActions/App, @userActions/Delegate, and @pages/inbox/report/ContextMenu/ReportActionContextMenu — a large graph with module-level Onyx connections, now cyclic with Navigation.

Add it next to the selector you already call one line above:

// src/selectors/Session.ts
const isDelegateSessionSelector = (session: OnyxEntry<Session>) => session?.authTokenType === CONST.AUTH_TOKEN_TYPES.DELEGATE;

Then isDelegateSessionSelector sits alongside isSupportalSessionSelector and the two checks read the same way.

2. Missing test on the path that actually caused the bug

Per your own analysis on the issue, the Not Found came from the proactive navigation, not from evaluate(). The new test only covers evaluate() (MigratedUserWelcomeModalGuard.test.ts:134). The onSessionOrLoadingAppChanged (proactive navigation) block has no delegate case, so line 51 is untested.

it('should not navigate during a copilot session', async () => {
    await Onyx.merge(ONYXKEYS.NVP_TRY_NEW_DOT, {nudgeMigration: {timestamp: new Date(), cohort: 'test'}});
    await waitForBatchedUpdates();
    mockNavigate.mockClear();

    onSessionOrLoadingAppChanged({authToken: 'test-token', accountID: 123, authTokenType: CONST.AUTH_TOKEN_TYPES.DELEGATE}, false);

    expect(mockNavigate).not.toHaveBeenCalled();
});

3. SubmitPlanWelcomeModalGuard has the identical bug

It is the same shape and excludes supportal only — line 130 (proactive) and line 311 (evaluate). A copilot who is eligible for the submit-plan modal and sits on a route outside its entryScreens hits the same "Hmm... it's not here". Worth adding here, or filing a follow-up so it doesn't get lost.


What I checked and what I didn't

Checked: delegate token is installed before the guard can fire; both guard entry points covered; hasRedirectedToMigratedUserModal is not set during the copilot session, so the delegator still gets the modal after disconnecting; import grouping matches the convention in src/libs/Navigation/AppNavigator/AuthScreensInitHandler.tsx; no import/no-cycle lint rule exists, so item 1 is a design concern rather than a CI failure.

Not checked: I did not run the manual test steps. They need two accounts, copilot access between them, and Account B in the nudge migration cohort with the modal undismissed — I can't provision that setup.


view run

@codecov

codecov Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
...Navigation/guards/MigratedUserWelcomeModalGuard.ts 100.00% <100.00%> (ø)
src/libs/Navigation/guards/index.ts 100.00% <ø> (ø)
src/selectors/Session.ts 100.00% <100.00%> (ø)
... and 23 files with indirect coverage changes

@VickyStash

Copy link
Copy Markdown
Contributor Author
  1. SubmitPlanWelcomeModalGuard has the identical bug

@MelvinBot It's not 100% the same, as SubmitPlanWelcomeModalGuard already falls back to Home when the active route isn't one of its entryScreens (getValidModalBasePath), so the user will not see the Not found page.

@MelvinBot review again

@MelvinBot

Copy link
Copy Markdown
Contributor

You're right and I was wrong — thanks for the correction. SubmitPlanWelcomeModalGuard calls getValidModalBasePath(), which validates the active route against entryScreens and falls back to ROUTES.HOME, so a copilot there lands on Home with the modal, not on Not Found. The asymmetry runs the opposite way from what I claimed.

Items 1 and 2 are addressed: isDelegateSessionSelector now sits beside isSupportalSessionSelector and the guards import from @selectors/Session, and the proactive path has a delegate test at MigratedUserWelcomeModalGuard.test.ts:442. No further changes needed from me on either.

One thing worth coordinating

That fallback is exactly what MigratedUserWelcomeModalGuard lacks — getMigratedUserWelcomeModalRoute uses Navigation.getActiveRoute() || ROUTES.HOME with no entryScreens check. Both modals share the same entry-screen list, where SETTINGS.ROOT is allowed but /settings/wallet is not. So a regular (non-copilot) user in the nudge migration who is on /settings/wallet when the NVPs resolve still gets Not Found. This PR removes the copilot trigger, not the underlying fragility.

That's tracked by Fix not-found page after clearing cache, still open. It touches MigratedUserWelcomeModalGuard.ts, SubmitPlanWelcomeModalGuard.ts, and tests/unit/Navigation/guards/MigratedUserWelcomeModalGuard.test.ts — the same files as this PR — so whichever merges second will conflict. Worth a heads-up to chrispader rather than a change here.

Minor nit and what I didn't verify

Nit (optional): isDelegateSession still exists in Session/index.ts:352-354 with the same body as the new selector, used by getImageSource.ts:28. Having the action call the selector would keep one definition, but it's cosmetic.

Not verified: I couldn't run tests/unit/Navigation/guards in this environment, so I reviewed the new tests by reading them rather than by execution. CONST is imported in the test file, so the CONST.AUTH_TOKEN_TYPES.DELEGATE reference resolves. I also did not run the manual steps — they need two accounts, copilot access, and Account B in the nudge migration cohort, which I can't provision.


view run

@mountiny

Copy link
Copy Markdown
Contributor

@codex review

@suneox can you review this one please?

@suneox

suneox commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

@codex review

@suneox can you review this one please?

Yes, i can review it soon

@garrettmknight garrettmknight left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good from a product perspective.

@suneox

suneox commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

I'm starting to review this PR

@suneox

suneox commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • 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 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)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The 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
  • 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 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.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this 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 have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
az_recorder_20260925_005217.1.mp4
Android: mWeb Chrome
iOS: HybridApp
CleanShot.2026-09-25.at.00.55.19.1.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari
CleanShot.2026-09-25.at.00.46.26.1.mp4

@suneox suneox left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skipping the migrated modal in copilot sessions LGTM

@mountiny mountiny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this improvement

@mountiny
mountiny merged commit 37552d2 into Expensify:main Sep 24, 2026
35 of 37 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 mountiny 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/mountiny in version: 9.4.94-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site changes are required for this PR, so I didn't create a docs PR.

This PR fixes a bug. It stops the migrated-user welcome modal from opening while a copilot is acting on another account. That fix resolves Copilot switch race fires OpenApp with no authToken, landing users on "Hmm... it's not here". It doesn't add or rename any UI labels, settings, or steps.

What I checked
  • Code changes: The PR only changes navigation guard logic, a session selector, and unit tests. It adds no user-facing copy.
  • Help site: No article under App/docs/articles mentions the migrated-user welcome modal.
  • Copilot articles: Act as a Copilot and Manage Copilot Access don't mention welcome modals or migration prompts. They stay accurate after this fix.

@VickyStash, no help site PR was needed for this change, so there is nothing to mark Ready for review.


view run

@izarutskaya

Copy link
Copy Markdown

@VickyStash Probably we don't have correct account for this setup. Can this be verified internally? Thank you

Account B has been added to the nudge migration and has not dismissed the migrated user welcome modal

@VickyStash

Copy link
Copy Markdown
Contributor Author

@VickyStash Probably we don't have correct account for this setup. Can this be verified internally? Thank you

@mountiny Maybe you have any idea how it can be tested with the real case?

@suneox

suneox commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Setup: Account B has been added to the nudge migration and has not dismissed the migrated user welcome modal

@izarutskaya That setup step can be dropped: nudgeMigration is only assigned by the BE when an account is added to a migration cohort, and the client can't opt in. We can just test the copilot switch as usual (A: Settings › switch to B) and it should land on B account without the Not Found page so I think QA can ignore this setup

@izarutskaya

Copy link
Copy Markdown

@suneox QA team faced with the issue #102441. It is repro in prod, can I check it off the list?

@Julesssss

Copy link
Copy Markdown
Contributor

Yes, I'll check it off. Thanks @izarutskaya @suneox

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/Julesssss in version: 9.4.94-0 🚀

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

Bundle Size Analysis (Sentry):

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.

8 participants