Skip to content

[Payment due @huult] Stop a client-side session age check from signing users out and dropping GPS trips - #97787

Merged
mountiny merged 31 commits into
Expensify:mainfrom
allgandalf:gps-trip-survives-forced-reauth
Aug 21, 2026
Merged

mountiny merged 31 commits into
Expensify:mainfrom
allgandalf:gps-trip-survives-forced-reauth

Conversation

@allgandalf

@allgandalf allgandalf commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

A forced SAML re-auth signs you out mid recording, and the Onyx.clear behind it wipes the in-progress GPS trip, so a long trip is lost. The trip is now kept across that re-auth. It also stores the accountID that started it, so the trip is dropped rather than offered when a different user signs in on the same device.

The attachment side is out of scope here, tracked in #92435.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/665676
PROPOSAL: n/a

Tests

Needs a SAML required account, so the re-auth signs you out instead of refreshing the token in the background.

On iOS or Android:

  1. Start a distance expense, pick the GPS tab and start a trip, then let it record some distance.
  2. Go to Settings > Troubleshoot > Authentication status, tap Invalidate with delay and wait ~15 seconds. Test tools are hidden on production, so use dev or staging.
  3. Complete the SAML sign in as the same user.
  4. Verify the Continue GPS trip recording? prompt appears and that Continue trip resumes with the earlier distance intact.
  5. Repeat steps 1 and 2, then cancel the IdP browser when it opens and sign in as a different user.
  6. Verify no trip prompt appears and the previous user's route is not shown.
  7. Start a trip on main, then switch to this branch and reopen the app.
  8. Verify the prompt still appears and Continue trip works, since a trip started before this change stores no accountID.
  • Verify that no errors appear in the JS console

Offline tests

  1. Start a GPS trip and go offline.
  2. Verify the trip keeps recording and no sign in redirect happens.

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 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.
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-08-12.at.15.17.37.mov

@codecov

codecov Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
...rc/components/GPSTripStateChecker/index.native.tsx 80.76% <100.00%> (+4.02%) ⬆️
src/libs/actions/SignInRedirect.ts 81.48% <100.00%> (+7.89%) ⬆️
src/libs/actions/GPSDraftDetails.ts 2.27% <0.00%> (+2.27%) ⬆️
...tep/IOURequestStepDistanceGPS/GPSButtons/index.tsx 0.00% <0.00%> (ø)
... and 20 files with indirect coverage changes

@allgandalf
allgandalf marked this pull request as ready for review August 12, 2026 09:51
@allgandalf
allgandalf requested review from a team as code owners August 12, 2026 09:51
@melvin-bot
melvin-bot Bot requested review from Eskalifer1 and joekaufmanexpensify and removed request for a team August 12, 2026 09:51
@melvin-bot

melvin-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

@Eskalifer1 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 August 12, 2026 09:51
@github-actions
github-actions Bot requested review from luacmartins and tgolen August 12, 2026 09:51
@github-actions

Copy link
Copy Markdown
Contributor

This PR adds a new Onyx.connectWithoutView call, so I've requested a review from the Onyx performance reviewers (@tgolen, @mountiny, @luacmartins) — a review from any one of them is enough. Please add a link in your PR description to the Slack discussion where the @frontend-performance team approved using connectWithoutView here.

@Eskalifer1

Copy link
Copy Markdown
Contributor

LMK if you need my help here!

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

Copy link
Copy Markdown

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: 08fac85824

ℹ️ 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/libs/actions/SignInRedirect.ts Resolved

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

Added one comment, other than that it looks good 👍 I tested GPS flows and they seem to be working fine

@huult

huult commented Aug 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-08-21.at.14.47.25.mov
Android: mWeb Chrome
iOS: HybridApp
Screen.Recording.2026-08-21.at.14.24.33.mov
iOS: mWeb Safari
MacOS: Chrome / Safari

@allgandalf

Copy link
Copy Markdown
Contributor Author

@huult dropped the attachment fix, only the GPS one is left here. attachment case moves to #92435

@allgandalf
allgandalf requested review from huult and mountiny August 21, 2026 08:01
@huult

huult commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

So, could you update the change description to reflect the new updates?

@huult

huult commented Aug 21, 2026

Copy link
Copy Markdown
Contributor
Screen.Recording.2026-08-21.at.15.15.56.mov

@allgandalf Could you double-check after your update? I can’t continue the trip anymore

@allgandalf

Copy link
Copy Markdown
Contributor Author

already updated, attachment steps are out and the GPS steps are renumbered

@allgandalf

Copy link
Copy Markdown
Contributor Author

good catch, real bug. a trip started before this build has no accountID so it got dropped. fixed in 87e9830, please retest

@huult

huult commented Aug 21, 2026

Copy link
Copy Markdown
Contributor
Screenshot 2026-08-21 at 17 20 05

@allgandalf Do we need to update this as well?

@allgandalf

Copy link
Copy Markdown
Contributor Author

good catch again, that para was still describing the attachment fix. rewritten, and added a step for the trip started before this change

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

LGTM.

Screen.Recording.2026-08-21.at.17.24.06.mov

@melvin-bot melvin-bot Bot changed the title Stop a client-side session age check from signing users out and dropping GPS trips [Payment due @huult] Stop a client-side session age check from signing users out and dropping GPS trips Aug 21, 2026
@melvin-bot

melvin-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

🎯 @huult, thanks for reviewing and testing this PR! 🎉

A payment issue will be created for your review once this PR is deployed to production.
E/E issue linked to the PR - https://www.github.com/Expensify/Expensify/issues/665676.

If payment is not needed (e.g., regression PR review fix etc), react with 👎 to this comment to prevent the payment issue from being created.

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

Looks good to me, the tests could be added in some follow up but also curious if Carlos and Tim want to review

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.

Can you also please follow the Given, when, then comments for tests?

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.

Same here

@mountiny

Copy link
Copy Markdown
Contributor

I dont want to hold this over the weekend due to the comments, lets just do a quick follow up later

@mountiny
mountiny merged commit 4d19d4d into Expensify:main Aug 21, 2026
39 of 41 checks passed
@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.

@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify OSBotify mentioned this pull request Aug 22, 2026
61 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.59-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

Help site review — no changes required

I reviewed this PR against the help site articles under docs/articles and no HelpDot changes are needed, so I did not open a docs PR.

Why: This is an internal bug fix that restores expected behavior for a narrow edge case. It stops a client-side session-age check from signing users out and dropping an in-progress GPS trip during a forced SAML re-auth, and it stamps the trip with the accountID that started it so a different user can't resume someone else's trip. No documented, user-facing workflow changes as a result.

What I checked

The GPS distance flow is already documented and remains accurate after this PR:

Neither article makes any claim about trips being lost on sign-out/re-auth, so there is no incorrect statement to correct. The change also doesn't introduce a new documented feature:

  • The trip-preservation change lives in src/libs/actions/SignInRedirect.ts (preserve GPS_DRAFT_DETAILS across an involuntary re-auth).
  • The accountID guard and the Continue GPS trip recording? prompt gating live in src/components/GPSTripStateChecker/index.native.tsx. The resume prompt itself is pre-existing behavior (it already appears on app restart), not something this PR adds — so it's out of scope for a docs update tied to this PR.

The behavior only triggers for SAML-required accounts undergoing a forced re-auth mid-trip, which isn't a workflow the help site documents.

@allgandalf, this is my read that no help-site update is needed for this PR — the documented GPS distance flow stays accurate. If you'd rather I add an FAQ entry about what happens to an in-progress GPS trip when you're signed out and back in (this resume/continue behavior is currently undocumented), reply with @MelvinBot and I'll draft one.


view run

@IuliiaHerets

IuliiaHerets commented Aug 24, 2026 •

Copy link
Copy Markdown

Hi @allgandalf. QA team attempted to test this flow, but Step 3 doesn’t seem to work as expected.
Step 3 says to complete the SAML sign-in as the same user. However, if we’re not signed in to the SAML account, we can’t start the distance expense and track the trip in Steps 1–2.
If we skip Step 3, the “Continue GPS trip recording?” prompt doesn’t appear.
Could you please clarify the expected flow here? Did we miss something, or could you test it on your side to confirm the expected behavior?

aaa.mp4

cc @luacmartins @mountiny @joekaufmanexpensify @tgolen

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/AndrewGable in version: 9.4.59-5 🚀

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

Bundle Size Analysis (Sentry):

@melvin-bot

melvin-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown

🤖 Payment issue created: #99363

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.