Skip to content

Redirect invited member to workspace chat instead of Home - #95418

Merged
madmax330 merged 2 commits into
Expensify:mainfrom
Abdulloh0109:fix/94549-invite-exitto-home
Jul 27, 2026
Merged

Redirect invited member to workspace chat instead of Home#95418
madmax330 merged 2 commits into
Expensify:mainfrom
Abdulloh0109:fix/94549-invite-exitto-home

Conversation

@Abdulloh0109

Copy link
Copy Markdown
Contributor

Explanation of Change

A first-time invitee opens a validate-login magic link that carries an exitTo destination (the workspace chat), e.g. /v/<accountID>/<validateCode>?exitTo=/r/<reportID>. On web this is handled by ValidateLoginPage.

The destination reaches the page correctly, but a second, competing navigation to Home fires and overwrites it. isUserClickedSignIn is meant to detect a separate-session magic-link sign-in (no cached login, just signed in) so its focus effect can redirect the user Home. A first-time invitee matches that condition exactly — no cached login, just signed in — and also carries an exitTo. So after sign-in two navigations race: handleExitToNavigation → the workspace chat, and the focus effect → navigate(ROUTES.HOME, {forceReplace: true}). The Home forceReplace wins and the member lands on Home.

The fix excludes exitTo from isUserClickedSignIn, so when a deep-link destination exists the Home redirect never fires and handleExitToNavigation owns the navigation. The separate-session case (no login, no exitTo) is unchanged, so that behavior isn't regressed.

Added a regression test in tests/ui/ValidateLoginPageTest.tsx that reproduces the invitee-with-exitTo state and asserts the Home redirect does not fire while handleExitToNavigation is invoked with the destination (fails without the fix, passes with it).

Fixed Issues

$ #94549
PROPOSAL: #94549 (comment)

Tests

  1. Log in as an admin of a workspace (or create one).
  2. Go to the workspace Members and invite a member by an email that has no Expensify account (use a real inbox that can receive the invite).
  3. Open the invited user's inbox and copy the validate-login link at the bottom of the invite email (it looks like /v/<accountID>/<validateCode>?exitTo=/r/<reportID>).
  4. In a fresh, logged-out browser session (incognito), open that link (no magic code needed — sign-in is automatic).
  5. Verify you are taken directly to the workspace chat, not the Home page.
  • Verify that no errors appear in the JS console

Offline tests

Not applicable — the flow is a validate-login sign-in that requires a network connection to complete. Once signed in, the exitTo destination navigation runs as in the Tests above.

QA Steps

Same as Tests, on staging (web — Windows/Chrome, macOS/Chrome/Safari, mWeb Chrome/Safari):

  1. As a workspace admin, invite a member by an email that has no Expensify account.
  2. From the invited inbox, open the validate-login invite link (change the domain to staging) in a fresh, logged-out browser session.
  3. Verify the member is redirected to the workspace chat, not the Home page.
  • 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 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 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.
  • 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
6ff31b56-0666-4ddf-b17a-5967515718d6.mp4

A first-time invitee opens a validate-login magic link that carries an
exitTo (the workspace chat). isUserClickedSignIn matched that case (no
cached login, just signed in) and its focus effect force-redirected Home,
clobbering handleExitToNavigation's exitTo navigation. Exclude exitTo from
isUserClickedSignIn so the Home redirect no longer fires when a deep-link
destination exists.

Fixes Expensify#94549
@Abdulloh0109
Abdulloh0109 requested review from a team as code owners July 6, 2026 17:48
@melvin-bot
melvin-bot Bot requested a review from hoangzinh July 6, 2026 17:48
@melvin-bot

melvin-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

@hoangzinh 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 heyjennahay and removed request for a team July 6, 2026 17:49
@Abdulloh0109

Copy link
Copy Markdown
Contributor Author

@heyjennahay @hoangzinh

@hoangzinh

Copy link
Copy Markdown
Contributor

@Abdulloh0109, could you please temporarily close or mark this PR as a draft? We are still waiting for the internal engineer to accept your proposal.

@Abdulloh0109

Copy link
Copy Markdown
Contributor Author

Are we still waiting? Should I close the PR, or should I leave it open? @hoangzinh

@hoangzinh

Copy link
Copy Markdown
Contributor

just leave it open. I will review the PR soon

@hoangzinh hoangzinh 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.

all goods. Just one minor comment

Comment on lines +65 to +69
// Exclude `exitTo` deep links (e.g. a workspace-chat invite link): those carry a specific
// destination that `handleExitToNavigation` owns, so this flag's Home redirect (focus effect
// below) must not fire and clobber it. Without `!exitTo`, a first-time invitee (no cached
// `login`, just signed in) matches this exactly and gets force-redirected Home instead of the
// workspace chat.

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.

I think we can write it shorter.

Suggested change
// Exclude `exitTo` deep links (e.g. a workspace-chat invite link): those carry a specific
// destination that `handleExitToNavigation` owns, so this flag's Home redirect (focus effect
// below) must not fire and clobber it. Without `!exitTo`, a first-time invitee (no cached
// `login`, just signed in) matches this exactly and gets force-redirected Home instead of the
// workspace chat.
// Exclude `exitTo` deep links (e.g. a workspace-chat invite link): those carry a specific
// destination that `handleExitToNavigation` owns, so this flag's Home redirect (focus effect
// below) must not fire and clobber it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call, done 👍

@hoangzinh

hoangzinh commented Jul 21, 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
Screen.Recording.2026-07-21.at.19.26.55.mov
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
Screen.Recording.2026-07-21.at.20.30.12.mov
MacOS: Chrome / Safari
Screen.Recording.2026-07-21.at.19.04.38.mov

@melvin-bot
melvin-bot Bot requested a review from madmax330 July 22, 2026 07:51
@Abdulloh0109

Copy link
Copy Markdown
Contributor Author

Why has it taken so long?

@Abdulloh0109

Abdulloh0109 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

Why was I unassigned from this job? What was the reason? @hoangzinh

@Abdulloh0109

Copy link
Copy Markdown
Contributor Author

@heyjennahay @madmax330

@hoangzinh

Copy link
Copy Markdown
Contributor

Why was I unassigned from this job? What was the reason? @hoangzinh

Can you elaborate it @Abdulloh0109? I saw you are still assigned to this issue

@madmax330
madmax330 merged commit fc0b881 into Expensify:main Jul 27, 2026
36 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 madmax330 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/madmax330 in version: 9.4.45-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

Help site review — no changes required

I reviewed the changes in this PR against the help site articles under App/docs/articles, and no help site updates are required. I did not create a draft docs PR.

Why: This is a purely internal navigation bug fix. It excludes exitTo deep links from the isUserClickedSignIn condition in src/pages/ValidateLoginPage/index.web.tsx so a first-time invitee opening a validate-login magic link lands on the workspace chat (via handleExitToNavigation) instead of being clobbered by a competing Home redirect. The only other change is a regression unit test.

What I checked
  • The change fixes a client-side navigation race for the invite magic-link flow (/v/<accountID>/<validateCode>?exitTo=/r/<reportID>). It restores the intended behavior (invitee → workspace chat) rather than introducing a new user-facing feature, setting, tab, button, or workflow.
  • I searched App/docs/articles for the affected concepts (member invites, magic/validate links, exitTo, workspace chat landing). The member-invite articles document how to invite members and assign roles, but none of them describe the internal magic-link deep-link mechanics or which specific screen an invitee lands on after clicking their invite link — so there is no documented behavior that this fix contradicts or that needs updating.
  • Reviewed against HELPSITE_NAMING_CONVENTIONS.md, HELP_AUTHORING_GUIDELINES.md, and TEMPLATE.md — no article edits fall out of this change.

⚠️ Browser-based verification was unavailable in this run, so this assessment is based on code and static analysis of the diff and the help-site content only.

@Abdulloh0109, since no help site PR was created, there's nothing to review or mark Ready for review. If you believe an article should document the post-invite landing behavior (and one doesn't exist today), reply with @MelvinBot and point me at the article you'd like created or updated, and I'll draft it.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/marcaaron in version: 9.4.45-14 🚀

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.

5 participants