Skip to content

Fix layers ordering in GPSMapView - #98891

Merged
mountiny merged 2 commits into
Expensify:mainfrom
software-mansion-labs:@GCyganek/gps-map/fix-layers-ordering
Aug 31, 2026
Merged

mountiny merged 2 commits into
Expensify:mainfrom
software-mansion-labs:@GCyganek/gps-map/fix-layers-ordering

Conversation

@GCyganek

@GCyganek GCyganek commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Fixes layer ordering in GPSMapView. Drops the current fragile logic (onDidFinishRenderingFrameFully + remounting via key) in favour of a new LayerOrderAnchors component rendering empty anchor layers. Waypoints and route now anchor to stable layer ids, keeping LocationPuck > Waypoints > Route order. Removes the platform-specific locationPuckLayerId files. This should fix bug where we don't show route & waypoints on the GPS map on iOS when belowLayerID points to a layer that has not been mounted yet.

Fixed Issues

$ #98965
PROPOSAL: N/A

Tests

  1. FAB > Track distance > GPS
  2. Verify that the map renders with the blue location puck visible on top of the map.
  3. Start GPS trip
  4. Verify that the route line is drawn below the waypoint markers (waypoint pins are not covered by the route line).
  5. Verify that the location puck is drawn on top of both the waypoint markers and the route line
  6. Stop GPS trip and verify 5. and 6. still applies
  7. Close and reopen the GPS screen, verify 5. and 6. still applies
  8. With waypoints and a route on the map, edit stop and save it.
  9. Verify that the layer ordering is still correct (puck above waypoints, waypoints above route) and there is no flicker or reordering of layers.
  10. Deny (or revoke in system settings) foreground location permissions and reopen the GPS tab.
  11. Verify that the fallback location marker is shown instead of the location puck, and that the route is still rendered below the waypoints.

backgrounded app:

  1. Start GPS distance tracking.
  2. Background the app and go on a trip (extended time backgrounded).
  3. Finish the trip and reopen the app.
  4. The route line should be drawn on the map when returning to the app after the trip.
  • Verify that no errors appear in the JS console

Offline tests

N/A

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.

Screenshots/Videos

Android: Native
Screen.Recording.2026-08-19.at.08.45.55.mp4
iOS: Native
Screen.Recording.2026-08-19.at.08.33.23.mp4

@GCyganek

Copy link
Copy Markdown
Contributor Author

@codex please review

@codecov

codecov Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
src/CONST/index.ts 94.85% <ø> (ø)
src/components/MapView/GPSMapView.tsx 2.63% <ø> (+0.33%) ⬆️
src/components/MapView/LayerOrderAnchors.tsx 33.33% <33.33%> (ø)
... and 471 files with indirect coverage changes

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 191b513d31

ℹ️ 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".

@GCyganek
GCyganek marked this pull request as ready for review August 19, 2026 09:46
@GCyganek
GCyganek requested review from a team as code owners August 19, 2026 09:46
@melvin-bot
melvin-bot Bot requested review from aimane-chnaif and heyjennahay and removed request for a team August 19, 2026 09:46
@melvin-bot

melvin-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown

@aimane-chnaif 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 19, 2026 09:46
@GCyganek

Copy link
Copy Markdown
Contributor Author

@dukenv0307 could you review as this is part of the GPS project?

@dukenv0307

Copy link
Copy Markdown
Contributor

on it now


/**
* Empty layers whose only purpose is to give other layers a stable position to anchor to via `belowLayerID`/`aboveLayerID`.
* This is needed as `belowLayerID`and `aboveLayerID` don't work well on native when they target layers that may not be

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.

Suggested change
* This is needed as `belowLayerID`and `aboveLayerID` don't work well on native when they target layers that may not be
* This is needed as `belowLayerID` and `aboveLayerID` don't work well on native when they target layers that may not be

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.

fixed

@dukenv0307

Copy link
Copy Markdown
Contributor

Code looks good

@dukenv0307

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-20.at.22.53.07.mp4
Android: mWeb Chrome
iOS: HybridApp
Screen.Recording.2026-08-20.at.22.45.47.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari

@dukenv0307

Copy link
Copy Markdown
Contributor

1 minor comment @GCyganek

@GCyganek

Copy link
Copy Markdown
Contributor Author

@heyjennahay in case you missed it

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

@mountiny
mountiny merged commit 5d4ea1b into Expensify:main Aug 31, 2026
38 of 41 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 OSBotify mentioned this pull request Aug 31, 2026
75 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

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

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site changes are required, so I did not create a draft PR.

This PR is an internal rendering fix only. It changes how Mapbox layers are ordered on the GPS map — it adds empty anchor layers (LayerOrderAnchors) so waypoints and the route line attach to stable layer IDs, replacing the onDidFinishRenderingFrameFully + remount-by-key approach and the platform-specific locationPuckLayerId files.

Nothing user-facing changes:

  • No new or renamed feature, tab, setting, or button
  • No copy changes (no src/languages/*.ts edits)
  • No change to the steps a member takes to create a GPS Distance expense
  • The visible result is that the puck, waypoints, and route now draw in the intended order — the same behavior the help site already implies
Docs I checked

The only articles that mention GPS tracking are:

The Distance Expenses article documents the flow (➕ Create → Track distance → GPS → Start / Stop / Resume / Save → Create expense), background tracking, and what the GPS receipt looks like. None of that is affected by this diff, and the article never describes map layer stacking. Every statement in it stays accurate after this change.

I did not run a UI test for this. GPS tracking is iOS/Android only, and this run's test platform is web, so a web run could not exercise the changed code path.

GCyganek — if you'd still like a docs update (for example, to add a line about how the route, waypoints, and location puck are layered on the map), reply and tell me what you want documented and I'll open the draft PR.


view run

@OSBotify

OSBotify commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/francoisl in version: 9.4.65-3 🚀

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