perf: narrow REPORT_NAME_VALUE_PAIRS subscription in ReportField#91961
Conversation
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: 62e9cf4d7e
ℹ️ 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".
| } | ||
| const result: OnyxCollection<OnyxTypes.ReportNameValuePairs> = {}; | ||
| for (const reportID of Object.keys(outstandingReports)) { | ||
| const key = `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}` as const; |
There was a problem hiding this comment.
Build NVP keys from unprefixed report IDs
The keys in outstandingReports are already full report collection keys (the derived value copies the Object.entries(reports) key, e.g. report_123), so prefixing them again here looks up reportNameValuePairs_report_123 instead of the real reportNameValuePairs_123. In any account with archived outstanding reports, this selector returns no matching NVP, so getOutstandingReportsForUser() cannot see private_isArchived and can include archived reports as selectable/default reports in this confirmation field.
Useful? React with 👍 / 👎.
|
@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] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f1be2d675
ℹ️ 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".
| const [reportNameValuePairs] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, {selector: createOutstandingReportsNVPsSelector(outstandingReportsForPolicy)}, [ | ||
| outstandingReportsForPolicy, | ||
| ]); |
There was a problem hiding this comment.
Narrow the remaining ReportField NVP subscription
This new scoped subscription does not actually stop unrelated report NVP updates from re-rendering ReportField, because the same component still calls useOutstandingReports(...) below, and that hook subscribes to ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS without a selector (src/hooks/useOutstandingReports.ts:16). In the scenario described by this PR—mutating an NVP on a report in another workspace—the hook still receives the full collection update and re-renders this row, so the intended perf fix remains ineffective unless the hook is also scoped or reused with the narrowed NVPs.
Useful? React with 👍 / 👎.
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeScreen.Recording.2026-05-29.at.7.40.55.PM.moviOS: HybridAppScreen.Recording.2026-05-29.at.8.04.35.PM.moviOS: mWeb SafariScreen.Recording.2026-05-29.at.8.07.31.PM.movMacOS: Chrome / SafariScreen.Recording.2026-05-29.at.12.55.16.PM.movScreen.Recording.2026-05-29.at.12.57.08.PM.mov |
|
@Julesssss looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
|
🚧 @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! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/Julesssss in version: 9.3.90-0 🚀
Bundle Size Analysis (Sentry): |
|
🤖 No help site changes required. I reviewed the changes in this PR against the help site files under Why: This is a pure performance optimization. It narrows the Details
Help site articles describe user-facing features and workflows. Since this change is invisible to end users (it only reduces re-renders), there is nothing in the docs to add or revise. Because no help site changes are required, I did not create a draft docs PR. If you believe a user-facing aspect of this change should be documented, reply with |
|
Hi @OlimpiaZurek. Can you please share more detailed QA steps, especially for step 4?
|
|
🚀 Deployed to production by https://github.com/lakchote in version: 9.3.90-3 🚀
|

Explanation of Change
ReportFieldsubscribed to the fullCOLLECTION.REPORT_NAME_VALUE_PAIRSwithout a selector — every NVP mutation across all reports re-rendered the confirmation page. The hook only needs NVPs for reports in the active policy's outstanding set (used byisReportOutstandingto check archived state).This adds a
createOutstandingReportsNVPsSelectorfactory that filters the collection down to those entries.useOnyx's deep-equality on selector output stops re-renders on unrelated NVP mutations.Fixed Issues
$ #90385
PROPOSAL:
Tests
Offline tests
QA Steps
// 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