Repository navigation
Fix Invalid URL error on the held expenses report link after a native cold start - #107441
Conversation
On native the report link helper is evaluated lazily on its first call, during render, so its async copy of the environment URL was still unset and links came out as undefined/r/<reportID>.
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
JmillsExpensify
left a comment
There was a problem hiding this comment.
No product review required.
Reviewer Checklist
Screenshots/VideosAndroid: HybridApp107441-after-android-native.mp4Android: mWeb Chromeweb cannot have this bug since it loads every module at startup.iOS: HybridApp107441-after-ios-native.mp4iOS: mWeb Safariweb cannot have this bug since it loads every module at startup.MacOS: Chrome / Safariweb cannot have this bug since it loads every module at startup. |
…oc environment cases
lakchote
left a comment
There was a problem hiding this comment.
Thanks @David-2002065, looks good.
|
🚧 lakchote has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/lakchote in version: 9.5.52-1 🚀
|
|
No help site update needed — this PR restores expected behavior for existing report links after reopening the app, without adding a workflow or making existing help instructions incorrect. |
Explanation of Change
On native, after a partial approval moves the held expense to a new report, reopening the app on that report logs
Error parsing URL(s): TypeError: Invalid URL: undefined/r/<reportID>.The "created this report for any held expenses from " message builds its href with
getReportURLForCurrentContext, which read a module-levelenvironmentURLthat was only filled by agetEnvironmentURL().then(...)scheduled when the module was evaluated. On native, the inline-requires loader turns every import into arequire()at its first use, and this helper is only called from a few rare messages, so after a cold start it gets evaluated inside its very first call, during render. The.thencan only run on a later microtask, so that first call returnsundefined/r/<reportID>, andAnchorRendererthrows while classifying it withnew URL(...). React Compiler then keeps the memoized output, so the broken link stays.This PR fixes it at the source for every caller of the helper (held expenses, moved report, unreported/self DM and harvest messages):
getEnvironment(native and web) exposes a syncgetCachedEnvironment(). On native it returns the valuegetEnvironmentalready cached, which is resolved long before any report renders since the API root waits on it. Dev/adhoc builds come straight from the config.Environment.tsexposesgetCachedEnvironmentURL()built from it.getReportURLForCurrentContextreadsgetCachedEnvironmentURL()on each call instead of its own async copy, so the very first call already has the real origin.Tests:
tests/unit/getReportURLForCurrentContextTest.tsloads the nativegetEnvironmentand a freshly evaluated helper, then calls it synchronously, the same as a cold start. Onmainboth cases returnundefined/r/123, with this change they return the dev and staging URLs.tests/unit/GetEnvironmentNativeTest.tscoversgetCachedEnvironment()returning the environment resolved by the beta check.Fixed Issues
$ #107179
PROPOSAL: #107179 (comment)
Tests
Precondition: User A invites User B to a workspace and sets User B as the approver.
Error parsing URL/Invalid URLerror is logged in the consoleOffline tests
Invalid URLerror is loggedQA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)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.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
android_native_after_107179.mp4
Android: mWeb Chrome
mweb_chrome_after_107179.mp4
iOS: Native
107179-after-ios.mp4
iOS: mWeb Safari
mweb_after_107179.mp4
MacOS: Chrome / Safari
web_chrome_after_107179.mp4