fix: Keep the sole GPS segment when a trip is stopped after one recorded point - #101027
Conversation
|
@mkhutornyi 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] |
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c80098738
ℹ️ 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".
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a5c7fcff1f
ℹ️ 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".
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f5852e0a3
ℹ️ 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".
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
|
🤖 Done — all five of my comments on this PR are now hidden as resolved:
Correcting my last reply: I said there was nothing to resolve because these were top-level comments rather than inline review threads. That was wrong — GitHub's Hide comment → Resolved works on top-level comments too, and that's what I've applied. Head is still Next Steps: Reply with view run · no recording available |
8f5852e to
77648b2
Compare
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
@MelvinBot @codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
|
🤖 Re-reviewed at Test step 3 now contradicts the codeStep 3 still says to verify "trash and pencil icons next to the distance". Commit While you're in there — the steps only exercise the first commit. Nothing covers the map centering on a single point, the stop marker on a segment that holds one point, or the Edit button disappearing. QA Steps say "Same as tests", so both sections inherit the gap. The rewrite dropped the
|
|
@MelvinBot The bug is already on main branch. I can make a follow-up. Addressing here will bloat up the PR. For now make the comment your wrote as resolved including all the others. |
|
🤖 Nothing left to resolve — and my main point is already fixed on your branch. All three inline review threads are already resolved, and no review is in a blocking state. My review was posted as a top-level PR comment, which GitHub gives no resolve control for. Treat it as closed out — I'm not holding anything open. You already applied the cleanup I asked for. At Agreed on the follow-up for the rest — the remaining One optional leftover whenever you touch this next: the view run · no recording available |
garrettmknight
left a comment
There was a problem hiding this comment.
Looks good from a product perspective.
Regression reviewI reviewed the diff against the surrounding GPS code. No blocking regression — the core change (keeping a trip's sole segment) is correct and the newly reachable 1. The Start and Stop rows can spin
|
…-GPS-Save-and-Resume-buttons-not-present-after-tapping-Stop-without-moving
…-GPS-Save-and-Resume-buttons-not-present-after-tapping-Stop-without-moving
|
Same as above. The are pre-existing planned as follow-ups. We can continue with the review. |
…-GPS-Save-and-Resume-buttons-not-present-after-tapping-Stop-without-moving
|
@MelvinBot @codex review |
|
🤖 Re-reviewed at The three commits since What I verified this roundI went deeper on the camera path, which I had only traced shallowly before. It holds up.
I also confirmed the newly reachable Nit: the reason in
|
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2026-09-18.at.10.16.03.AM.movAndroid: mWeb ChromeiOS: HybridAppScreen.Recording.2026-09-18.at.10.16.52.AM.moviOS: mWeb SafariMacOS: Chrome / Safari |
|
🤖 I traced every state the "keep the sole segment" change makes newly reachable. No functional regression found in the diff — CI is green, and the two riskiest-looking changes hold up (details below). Three things are worth a decision before merge. 1. A zero-distance trip now lives until the user explicitly discards it
Before, an accidental Start → Stop self-cleared and the tab was back at Start. Now that user gets Resume / Save on a 0.00 trip on every later visit — including when they open Track distance from a different chat, since the draft is a single global key. Abandoned real trips already behaved this way, so this is the fix's intended cost, not a defect. Please confirm it matches the expectation in Android - GPS - "Save" and "Resume" buttons not present after tapping "Stop" without moving. 2. The discard-race guard also swallows a failed readindex.native.ts:82 bails on any falsy result, but the value comes from 3. Two guards for one rule
What I checked that came back clean
4. Minor: a one-point trip renders only the green Start pinWith one waypoint entry, One caveat on verification: this flow is native-only — the tracking task and the GPS step are Next Steps: Reply with |
|
🤖 Code quality review — the diff is clean, well-commented, and unusually well-tested for a fix this size. The comments explain why rather than what, which is exactly right. Five things I'd tighten, roughly in order of value. 1. "The last segment has one point" is now expressed twice, in two incompatible waysGPSDraftDetailsUtils.ts:118 already owns this concept as Two spellings of the same idea that deliberately disagree is the kind of thing that rots. Both are really asking a question about trip shape, so both belong in While you're there: 2. The "can't trim below one interval" rule now lives in two filesGPSDraftDetailsUtils.ts:195 encodes it as 3. GPSMapView's camera now resolves across four overlapping expressions
Deriving one camera target with an explicit precedence chain (fallback → single point → bounds → follow user) and reading every consumer off it would collapse all four sites and make the asymmetry impossible. 4.
|
| // Dropping the sole segment would leave no points, which reads as a trip that never started | ||
| if (gpsPoints.length > 1) { | ||
| removeLastSegment(gpsPoints); | ||
| } |
There was a problem hiding this comment.
So this part is the core fix - restores exactly the guard that #90237 added and #91418 deleted.
The other 6 files
A stopped trip with exactly one point was previously an unreachable state, so everything downstream of isTripStopped now has to handle it. 3 of 4 are genuine consequences; one is scope creep.
| Change | Verdict |
|---|---|
useGPSWaypointMarkers changes replaces the index % 2 === 1 end-marker parity check with "last non-empty segment has >1 point" |
Needed. Parity assumed every segment yields 2 waypoints. A surviving 1-point segment yields 1, so [[p1],[p2,p3]] (start → stop → resume → move → stop) produced an odd count and lost its end marker. Newly reachable because of the fix. |
GPSMapView + MapView/utils changes getSinglePointCoordinate, center at fixed zoom instead of fitBounds |
Needed. While tracking, shouldFollowUserLocation is true so bounds are ignored. After Stop with 1 waypoint it flips false, and getBounds returns southWest === northEast — fitBounds on a zero-area box max-zooms the camera. Only reachable post-fix. |
canGpsTripBeTrimmed + EditGPSTripButton changes hides Edit when distanceInMeters <= 100 |
Needed, but indirect. Edit was gated on isTripStopped, so it now appears on a 0-distance trip. The distance threshold is a proxy; getTotalGpsTripPoints(...) > 1 says what's actually meant and avoids hiding Edit on a real 2-point trip measuring exactly 100 m. |
backgroundLocationTrackingTask.updateStartAddress changes bail out if the draft vanished during reverse geocoding |
Scope creep, borderline. Pre-existing discard-resurrection race. Arguably newly reachable (DiscardGPSTripButton is also gated on isTripStopped, so "start → stop → discard while the start-point geocode is in flight" only exists after the fix), but it's a distinct bug and belongs in its own PR. |
| defaultSettings={defaultSettings} | ||
| centerCoordinate={shouldFollowFallbackLocation ? centerCoordinate : undefined} | ||
| centerCoordinate={shouldFollowFallbackLocation ? centerCoordinate : waypointsCenterCoordinate} | ||
| zoomLevel={waypointsZoomLevel} |
There was a problem hiding this comment.
Worth verifying on device
This adds zoomLevel={waypointsZoomLevel} to the Camera - a prop it never had.
During tracking with one point recorded, singlePointCoordinate is truthy, so the Camera now gets centerCoordinate + zoomLevel: 15 while followUserLocation is also true.
rnmapbox should let follow-mode win, but controlled camera props fighting follow-mode has been flaky historically.
Confirm the map still tracks the user normally between the first and second recorded point.
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 AndrewGable has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/AndrewGable in version: 9.4.90-0 🚀
|
|
🤖 Yes, help site changes are required. Draft PR: Docs updates for E/A#101027 GPS trip stopped without moving Two statements in docs/articles/new-expensify/reports-and-expenses/Distance-Expenses.md no longer match what this PR ships:
What the docs PR changes
I checked the other GPS-related articles. Create-an-Expense.md lists the GPS steps only through Save and links to Distance Expenses for the rest, so it stays accurate and needed no edit. Every UI label was verified against the strings the app renders in src/languages/en.ts:10316-10340 — Start, Stop, Resume, Save, Edit stop, Total distance, Can't create expense, Got it. The GPS screens are mobile only, so they can't be opened on web to screenshot. I also couldn't run cspell locally (sandbox blocked it); CI will check spelling on the docs PR. The PR is a draft, labelled @TaduJR, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR |
Explanation of Change
Standing still while tracking records only one location, because the app records a new location only after you move 100 m. When you tapped Stop, the app removed the last section of the trip if it had one location or none. That's right for a section added by Resume that recorded nothing useful, but it also happened when that section was the whole trip. The app treats a trip with no locations as one that never started, so the trip disappeared: no Resume or Save, no distance or addresses, and the button went back to Start.
Stop now only removes a short section when there's an earlier section to fall back on. So stopping without moving keeps the trip with Resume and Save, and tapping Save shows the existing "Can't create expense" message. The same applies when a trip is stopped from "View trip" after reopening the app, or by switching to Expensify Classic.
Keeping that one location makes a few new situations possible, and this PR handles them:
This is a regression from #91418. The check that keeps a trip's only section was first lost in #88609, restored by #90237, then removed again by #91418, which also made Stop clear the only section. This PR restores the check and removes the clearing.
Fixed Issues
$ #100938
PROPOSAL:
Tests
Offline tests
Same as tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Screen.Recording.2026-09-12.at.7.51.01.PM.mov
Android: mWeb Chrome
iOS: Native
Screen.Recording.2026-09-12.at.7.58.04.PM.mov
iOS: mWeb Safari
MacOS: Chrome / Safari