Repository navigation
[Payment due @huult] Stop a client-side session age check from signing users out and dropping GPS trips #97787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mountiny
merged 31 commits into
Expensify:main
from
allgandalf:gps-trip-survives-forced-reauth
Aug 21, 2026
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
204c2ae
Add accountID to the GPS draft so it can be owner-checked
allgandalf 0096067
Stamp the starting user on the GPS draft
allgandalf 4161915
Keep the GPS trip across a forced SAML re-auth
allgandalf 2cab489
Only keep a live trip, and stamp its owner on the way out
allgandalf b148569
Never offer a resumed trip to a different user
allgandalf 226ad5f
Rename the owner flag to satisfy no-negated-variables
allgandalf e369d33
Cover the GPS trip surviving a forced re-auth
allgandalf cfdb42a
Do not let an image reauth sign the user out when it cannot refresh s…
allgandalf 637feab
Keep a valid attachment token instead of blanking on a session-age guess
allgandalf 08fac85
Merge branch 'Expensify:main' into gps-trip-survives-forced-reauth
allgandalf d9bddf3
Move canReauthenticateSilently next to the branches it predicts
allgandalf 20485c7
Say why the GPS draft read has to be a subscription
allgandalf 6b0d9e5
Do not suppress reauth before Onyx has loaded credentials
allgandalf 86eb524
Never keep a GPS trip we cannot record an owner for
allgandalf c854287
Simplify the canReauthenticateSilently doc
allgandalf 5a0a1ec
Merge remote-tracking branch 'upstream/main' into HEAD
allgandalf 88ccfa3
Read the GPS draft on demand instead of subscribing to it
allgandalf a67e9df
Merge remote-tracking branch 'upstream/main' into HEAD
allgandalf 6d92bb9
Preserve the trip without reading Onyx during sign out
allgandalf 63052b7
Check trip ownership with useOnyx once the session has loaded
allgandalf ff2210a
Seed the trip owner the way a real trip records it
allgandalf 95222c0
Merge remote-tracking branch 'upstream/main' into HEAD
allgandalf 6f039fb
Use the shared accountID selector
allgandalf e60f191
Merge remote-tracking branch 'upstream/main' into gps-trip-survives-f…
allgandalf b489379
revert unintended formatting changes
allgandalf e972ed8
revert unintended formatting changes in AuthScreensInitHandler
allgandalf b9508bc
Merge remote-tracking branch 'upstream/main' into HEAD
allgandalf b66fdf8
move the attachment fix to a follow up
allgandalf 1fa2818
shorten comments
allgandalf 87e9830
keep a trip that records no accountID
allgandalf 3693f10
add test for the trip owner check
allgandalf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import {render} from '@testing-library/react-native'; | ||
|
|
||
| import ComposeProviders from '@components/ComposeProviders'; | ||
| import GPSTripStateChecker from '@components/GPSTripStateChecker/index.native'; | ||
| import {LocaleContextProvider} from '@components/LocaleContextProvider'; | ||
| import OnyxListItemProvider from '@components/OnyxListItemProvider'; | ||
|
|
||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import {SplashScreenStateContextProvider} from '@src/SplashScreenStateContext'; | ||
| import type {GpsDraftDetails} from '@src/types/onyx'; | ||
|
|
||
| import React from 'react'; | ||
| import Onyx from 'react-native-onyx'; | ||
|
|
||
| import getOnyxValue from '../../utils/getOnyxValue'; | ||
| import waitForBatchedUpdatesWithAct from '../../utils/waitForBatchedUpdatesWithAct'; | ||
|
|
||
| jest.mock('@libs/Navigation/Navigation', () => ({ | ||
| __esModule: true, | ||
| default: {navigate: jest.fn()}, | ||
| })); | ||
|
|
||
| jest.mock('@pages/iou/request/step/IOURequestStepDistanceGPS/GPSNotifications', () => ({ | ||
| startGpsTripNotification: jest.fn(), | ||
| stopGpsTripNotification: jest.fn(), | ||
| updateGpsTripNotificationDistance: jest.fn(), | ||
| updateGpsTripNotificationUnit: jest.fn(), | ||
| updateGpsTripNotificationLanguage: jest.fn(), | ||
| checkAndCleanGpsNotification: jest.fn(() => Promise.resolve()), | ||
| shouldUpdateGpsNotificationUnit: jest.fn(() => false), | ||
| })); | ||
|
|
||
| const CURRENT_ACCOUNT_ID = 1; | ||
| const OTHER_ACCOUNT_ID = 2; | ||
|
|
||
| const trip: GpsDraftDetails = { | ||
| gpsPoints: [[{lat: 1, long: 2}]], | ||
| distanceInMeters: 100, | ||
| isTracking: true, | ||
| reportID: '1', | ||
| unit: CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES, | ||
| }; | ||
|
|
||
| function renderChecker() { | ||
| return render( | ||
| <ComposeProviders components={[OnyxListItemProvider, LocaleContextProvider, SplashScreenStateContextProvider]}> | ||
| <GPSTripStateChecker /> | ||
| </ComposeProviders>, | ||
| ); | ||
| } | ||
|
|
||
| describe('GPSTripStateChecker', () => { | ||
| beforeAll(() => { | ||
| Onyx.init({keys: ONYXKEYS}); | ||
| }); | ||
|
|
||
| beforeEach(async () => { | ||
| await Onyx.clear(); | ||
| await Onyx.merge(ONYXKEYS.SESSION, {accountID: CURRENT_ACCOUNT_ID}); | ||
| await waitForBatchedUpdatesWithAct(); | ||
| }); | ||
|
|
||
| it('keeps a trip that records no accountID, because it predates the trip owner being stored', async () => { | ||
| await Onyx.merge(ONYXKEYS.GPS_DRAFT_DETAILS, trip); | ||
| await waitForBatchedUpdatesWithAct(); | ||
|
|
||
| renderChecker(); | ||
| await waitForBatchedUpdatesWithAct(); | ||
|
|
||
| expect((await getOnyxValue(ONYXKEYS.GPS_DRAFT_DETAILS))?.isTracking).toBe(true); | ||
| }); | ||
|
|
||
| it('keeps a trip started by the signed in user', async () => { | ||
| await Onyx.merge(ONYXKEYS.GPS_DRAFT_DETAILS, {...trip, accountID: CURRENT_ACCOUNT_ID}); | ||
| await waitForBatchedUpdatesWithAct(); | ||
|
|
||
| renderChecker(); | ||
| await waitForBatchedUpdatesWithAct(); | ||
|
|
||
| expect((await getOnyxValue(ONYXKEYS.GPS_DRAFT_DETAILS))?.isTracking).toBe(true); | ||
| }); | ||
|
|
||
| it('discards a trip started by a different user', async () => { | ||
| await Onyx.merge(ONYXKEYS.GPS_DRAFT_DETAILS, {...trip, accountID: OTHER_ACCOUNT_ID}); | ||
| await waitForBatchedUpdatesWithAct(); | ||
|
|
||
| renderChecker(); | ||
| await waitForBatchedUpdatesWithAct(); | ||
|
|
||
| expect(await getOnyxValue(ONYXKEYS.GPS_DRAFT_DETAILS)).toBeUndefined(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?