perf: only subscribe to policies in IOURequestStepConfirmation while the participant picker is open - #99544
Conversation
…the participant picker is open
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.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 22917021bf
ℹ️ 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".
|
@cretadn22 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: HybridAppScreen.Recording.2026-08-27.at.09.00.22.movAndroid: mWeb ChromeScreen.Recording.2026-08-27.at.08.57.56.moviOS: HybridAppScreen.Recording.2026-08-27.at.08.58.56.moviOS: mWeb SafariScreen.Recording.2026-08-27.at.09.01.00.movMacOS: Chrome / SafariScreen.Recording.2026-08-27.at.08.53.59.mov |
|
@OlimpiaZurek Just noticed that IOURequestStepConfirmation still seems to subscribe to the full policy collection through useParticipantsPolicies hook |
|
The policy parameter is missing from being passed in this spot |
This PR removes the |
The parameter isn't needed here because handleSelectionChange only runs for splits, and handleParticipantsAdded only reads selectedPolicy for non-split expenses. That's why it's optional rather than required. |
…tion # Conflicts: # src/pages/iou/request/step/IOURequestStepConfirmation.tsx
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 60df7c4e41
ℹ️ 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".
| // Resolve the chosen workspace's policy and pass it up so the confirmation step can reset the rate and category | ||
| // without subscribing to every policy. allPolicies is already loaded on this screen, so this adds no new subscription. | ||
| const selectedPolicy = option.policyID ? allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${option.policyID}`] : undefined; |
There was a problem hiding this comment.
Mount the policy subscriber only while the picker is visible
On web and Android, this does not actually limit the policy subscription to an open picker: ParticipantPicker/index.tsx intentionally keeps BaseParticipantPicker mounted when isVisible is false, so ParticipantSearchResults and its useOnyx(ONYXKEYS.COLLECTION.POLICY) subscription remain active for the confirmation page's entire lifetime. Consequently high-traffic accounts still load and react to the full policy collection on the confirmation screen; the picker content or its policy-dependent subtree needs to be gated by visibility while preserving the modal shell required for its exit animation.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The purpose of this change appears to be removing a redundant subscription in IOURequestStepConfirmation
|
🚧 Julesssss 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/Julesssss in version: 9.4.64-0 🚀
|
|
No help site changes are required for this PR, so I have not created a draft docs PR. This is an internal performance refactor with no user-facing change. What I checkedAll five changed files are component internals, prop types, or tests:
There are no new or renamed features, tabs, settings, buttons, or copy strings. The help site articles that cover this area — Distance Expenses and Set distance rates — describe the user-facing flow, which this PR does not alter. They remain accurate as written. If you would still like a docs PR for something related that this change surfaced, reply with |
Explanation of Change
IOURequestStepConfirmationsubscribed to the whole policy collection on every mount, but only used it insidehandleParticipantsAdded, to find the destination workspace's rate and category defaults when the user switches recipient. That subscription and the map over every policy sat on the confirmation's first render for something first render never touches, and the cost grows with the number of workspaces.Now the participant picker passes that policy instead.
ParticipantSearchResultsalready subscribes to policies and only mounts while the picker is open, so it resolves the selected workspace's policy and passes it as an optional second argument toonParticipantsAdded. The confirmation reads it there and no longer subscribes to policies at all.The argument is optional, so the other
onParticipantsAddedcallers (the standalone participant step and the Share flow) are unchanged. The policy is only read, never attached to the participant, so nothing extra is written to the draft transaction.Fixed Issues
$ #99671
PROPOSAL:
Tests
Offline tests
QA Steps
Same as tests
// TODO: These must be filled out, or the issue title must include "[No QA]."
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