Repository navigation
perf: shrink SearchRouter's initial recent-reports build, paginate on scroll - #95683
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a877117d42
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 82783475b1
ℹ️ 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".
8edfafd to
82e15dd
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 82e15ddc62
ℹ️ 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".
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ 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". |
|
cc: @shubham1206agra |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3dbab84da2
ℹ️ 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".
| useEffect(() => { | ||
| if (trimmedAutocompleteQueryValue !== '' || isLoadingOptions || suggestionsCount > 0 || !hasMoreRecentReports) { | ||
| return; | ||
| } | ||
| loadMoreRecentReports(); |
There was a problem hiding this comment.
Throttle empty-list pagination to avoid render loops
When the blank SearchRouter opens for an account whose raw reports keep getting filtered out (for example many hidden chats, or no visible chats at all), suggestionsCount stays 0, so this effect calls loadMoreRecentReports() after every render until hasMoreRecentReports becomes false or a row finally appears. Each call synchronously bumps the cap and rebuilds createFilteredOptionList over the report collection, so high-traffic accounts can do dozens of immediate renders/recomputations on open and may hit React's update-depth guard before anything is displayed; this should be capped, deferred, or limited to one retry per frame/user scroll.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
It has been addressed!
3dbab84 to
37277dd
Compare
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.
|
|
@WojtekBoman, is @shubham1206agra reviewing this? If yes, I will assign them for reviewer. |
Yes :) @shubham1206agra will review this |
Reviewer Checklist
Screenshots/VideosScreen.Recording.2026-07-16.at.6.51.59.PM.mov |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 mountiny 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/mountiny in version: 9.4.41-0 🚀
|
Help site review: no docs changes requiredI reviewed the changes in this PR against Expensify's help site articles under Why: This is a pure performance optimization of how SearchRouter builds its recent-reports option list. As the PR description states, the recent-reports view is still capped at 20 rows exactly as before, ordering is unchanged, and search behavior is unaffected — the I searched Note: I could not verify this in a browser (NewDot web browser control was unavailable in this run), so this assessment is based on static analysis of the diff and the help-site articles alone. @WojtekBoman, since no help site changes are required, I did not create a draft docs PR. If you believe a user-facing behavior did change and docs should be updated, let me know and I'll create one. |
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.4.41-4 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
SearchRouter built full option data for the default ~500-report recent-reports list on every open, even though the recent-reports view only ever shows up to 20 rows (
CONST.AUTO_COMPLETE_SUGGESTER.MAX_AMOUNT_OF_SUGGESTIONS). This PR makes that build lazy without changing anything the user sees:useFilteredOptionsnow starts with a 100-report cap (INITIAL_MAX_RECENT_REPORTS) instead of building option data for all ~500 raw reports up front.loadAll) so the remaining slots fill from less-recent reports. This runs at most once per open and only in that under-fill case; when the initial 100-report window already fills the 20 visible slots, nothing extra is built. There is no scroll-driven pagination, since the view is capped at 20 rows and can never show more.isSearchingdrops the limit increateFilteredOptionList), so search suggestions are unaffected.recentReportComparatorhad a chance to keep it, by mirroring the self-DM priority inreportSortComparator.This is a pure performance optimization. The recent-reports view is still capped at 20 rows exactly as before — the
loadAllescalation is an internal mechanism to top up those 20 slots when the initial 100-report window has too many filtered-out reports, not user-facing infinite scroll.Measured over 19 warm opens of SearchRouter:
Android native:
Web:
Fixed Issues
$ #79353 (comment)
PROPOSAL:
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, 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.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
Screen.Recording.2026-07-17.at.11.01.29.mov