perf: precompute RBR transaction set in MoneyRequestReportTransactionList#91710
Conversation
|
@bernhardoj 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: 485516eb82
ℹ️ 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".
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid.movAndroid: mWeb ChromeiOS: HybridAppios.moviOS: mWeb SafariMacOS: Chrome / Safariweb.mov |
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.
|
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ 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". |
|
Lint failing |
|
Code Review: Looks good. The optimization is sound and behaviorally equivalent to the old approach. Review detailsCorrectness: The old Performance: Old code called
Null guard: No dead code: Note on ESLint failure: The lint error is in |
|
PR doesn’t need product input as a performance PR. Unassigning and unsubscribing myself. |
|
No regressions found. The change is functionally equivalent to the original Investigation detailsSort behavior preserved:
No test changes needed: Existing tests for |
|
Codex Review: Didn't find any major issues. Bravo. ℹ️ 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". |
|
🚧 @mountiny 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/mountiny in version: 9.3.84-0 🚀
Bundle Size Analysis (Sentry): |
|
No help site changes are required for this PR. This is a performance optimization that precomputes RBR-flagged transaction IDs into a @TMisiukiewicz, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR |
|
This PR failing because of the issue #91935 |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.86-0 🚀
Bundle Size Analysis (Sentry): |
|
I reviewed the changes in this PR. This is a performance optimization only — it precomputes a No help site changes are required. There are no user-facing behavior changes, no new features, no UI modifications, and no terminology updates — just an internal optimization to reduce sort cost from O(n log n · R) to O(n · R). @TMisiukiewicz, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.88-0 🚀
Bundle Size Analysis (Sentry): |
|
No help site changes are required for this PR. This is a performance optimization that precomputes a @TMisiukiewicz, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR |
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.3.88-2 🚀
|
Explanation of Change
Opening a money request report with many transactions was spending ~2s inside
compareByRBRon iOS for 1.6k transactions. The root cause: the sort comparator calledtransactionHasRBR(a)andtransactionHasRBR(b)for every pair the sort visited — each call walks thereportActionsrecord via.some, making the total cost O(n log n · R) where R is the number of report actions per transaction.Fix: before sorting, do a single O(n) pass over transactions and build a
Setof every RBR-flagged transaction. The comparator then becomes twoSet.haslookups — O(1) per pair. Total RBR classification cost drops from O(n log n · R) to O(n · R), and theSetis only computed when the default sort (Date/ASC) is active.ManualOpenReportfor the report with 1.6k transactions on iOS: 7s -> 5.1sFixed Issues
$ #91714
PROPOSAL:
Tests
Offline tests
N/A
QA Steps
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
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-05-26.at.13.29.38.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-05-26.at.13.25.37.mov