perf: narrow usePolicyForTransaction policy collection subscription#91954
Conversation
|
Codex Review: Didn't find any major issues. 🎉 ℹ️ 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". |
|
@ShridharGoel 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] |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeScreen.Recording.2026-05-29.at.2.08.35.AM.moviOS: HybridAppScreen.Recording.2026-05-29.at.2.03.39.AM.moviOS: mWeb SafariScreen.Recording.2026-05-29.at.2.04.57.AM.movScreen.Recording.2026-05-29.at.2.05.40.AM.movMacOS: Chrome / SafariScreen.Recording.2026-05-29.at.2.00.18.AM.mov |
|
🚧 @Julesssss 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! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/Julesssss in version: 9.3.90-0 🚀
Bundle Size Analysis (Sentry): |
This comment was marked as off-topic.
This comment was marked as off-topic.
|
🚀 Deployed to production by https://github.com/lakchote in version: 9.3.90-3 🚀
|
Explanation of Change
Replaces the unscoped
useOnyx(COLLECTION.POLICY)inusePolicyForTransactionwith aselectorparameterized bycustomUnitID. The hook is used by 10+ IOU step call sites, so every policy mutation across all workspaces was re-rendering every consumer. Selector + deep-equality limits re-renders to when the resolved policy actually changes. Drops the redundantuseMemo(selector handles memoization).Results from profiling ( scenario: confirmation page open (policy-expense flow), then triggered an unrelated mutation (add/remove a tag in workspace):
🟢 Duration Diff: -176.700 ms (-17.3%)
🟢 Commit Count Diff: -8
Fixed Issues
$ #90385
PROPOSAL:
Tests
Offline 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 stepssectiontoggleReportand 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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari