Repository navigation
Move the unread indicator onto useOnyx so report updates stop slowing down - #104568
Conversation
Several report_ subscribers redid work over every report on each write, even when nothing they use changed: - UnreadIndicatorUpdater: memoize used deep equality with no size limit, so each write added a cache entry and deep-compared all previous reports snapshots; keep only the last call, compared by reference - replaceOptimisticReportWithActualReport: skip reports without preexistingReportID early - Parser and ReportUtils: build reportIDToNameMap and reportsByPolicyID lazily - WideRHPContextProvider: select only invoice/task report keys - FAB and floating camera button: stop at the first workspace chat - SuggestionMention: select mentionable room names instead of full reports
- Unread indicator memo keeps one cache entry across report updates and reuses the result for the same collection - Parser report mentions use the current report name after a rename - getFirstWorkspaceChat matches the first result of getWorkspaceChats
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
Drop the ReportUtils policy grouping, FAB first-workspace-chat and mention-names changes; each saved under 2 ms per report update.
Revert the Parser, replaceOptimisticReportWithActualReport and WideRHPContextProvider changes. They save only a few ms each, so they will go through metric issues as separate PRs.
The unread count now lives in a small UnreadIndicatorUpdater component that reads its data with useOnyx and lets React Compiler cache the result, so the module-level Onyx subscriptions, the memoize cache and the debounce go away. The counting logic is a pure function that takes all its data as arguments.
…write-perf # Conflicts: # src/libs/UnreadIndicatorUpdater/index.ts
|
@abdulrahuman5196 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] |
Hi is there anything you need from me to push the review forward ? :) |
|
Hi, Checking now |
|
@MelvinBot review |
1 similar comment
|
@MelvinBot review |
|
🤖 Web test steps verification results: Completed onboarding and exercised Account settings → Inbox on dev NewDot web. Unread-count assertions remain blocked by fixture and tooling limitations; no product failure was established.
|
|
🤖 Web test steps verification results: Verified navigation on dev NewDot web, but unread-count correctness remains unverified. Only the existing Concierge conversation was available; no messages or accounts were fabricated.
|
|
Hi, so is there anything you need from me about this pr ? I see ,Melvin tested it but seems like its better to also have qa to test as it seems didn't finish. |
|
Hi @abdulrahuman5196 any update on this ? |
|
Hi, Checking now again |
|
@MelvinBot I see you tried to run the tests, but did you run the code review? |
|
Not a complete code review. I inspected the diff and some related code, but did not finish a systematic review or report code findings. My previous replies covered attempted test verification only—not a code-review verdict. Sorry for missing that part of your request. |
|
@MelvinBot Could you kindly do a code review of this PR? |
Code reviewReviewed all eight changed files and the related navigation, Onyx, and unread-publication code at Finding: P2 — Avoid deep-comparing the entire report-attributes mapIn src/components/UnreadIndicatorUpdater/index.tsx:20–22, the selector returns the complete Subscribe without a selector and access Test coverageThe new tests cover initial publication and marking a report read. Additional regression coverage would be useful for navigation/draft changes, foreground refresh, and Concierge-response completion, especially because the registered callback now republishes a render-time snapshot rather than recalculating. No other definite blocking defect found. This was a static code review; I did not rerun tests or independently validate the performance measurements. |
The selector returned the whole reports map, so Onyx deep-compared it on every derived-value write. Use useReportAttributes() for reference comparison, and cover navigation and foreground republish in tests.
ok I addressed those |
|
Hi @abdulrahuman5196 is there an update ? |
|
Hi is there anything that I should do to promote it to be merged ? @abdulrahuman5196 |
|
@elirangoshen the code looks good to me. Could you kindly fix the TS errors? I can proceed to platform specific testing then |
done |
|
checking now |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroidHybrid-0-Screen_Recording_2026-11-17_at_12.28.13.AM.movAndroid: mWeb ChromeandroidMWeb-0-Screen_Recording_2026-11-17_at_12.32.39.AM.moviOS: HybridAppiosHybrid-0-Screen_Recording_2026-11-17_at_12.12.47.AM.moviOS: mWeb SafariiosMWeb-0-Screen_Recording_2026-11-17_at_12.14.34.AM.movMacOS: Chrome / SafarimacOS-0-Screen_Recording_2026-11-16_at_11.47.37.PM.mov |
abdulrahuman5196
left a comment
There was a problem hiding this comment.
Changes looks good and works well. Reviewers checklist is also complete.
All yours.
🎀 👀 🎀
C+ Reviewed
|
🚧 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.5.41-0 🚀
|
|
No help site update needed — this PR refactors unread-indicator calculations for performance without adding a feature, changing user workflows, removing a beta, or making existing article text incorrect. |
|
🚀 Deployed to production by https://github.com/marcaaron in version: 9.5.41-2 🚀
Bundle Size Analysis (Sentry): |


Explanation of Change
The unread indicator (browser tab title on web, app badge on iOS) counts unread reports after every report update. It ran as a plain module: it read reports, report actions, name-value pairs, drafts and report attributes through
Onyx.connectWithoutView, and cached the count withmemoize. That cache compared deeply and had no size limit. Every report update passes a newreportscollection, so the cache never matched: each update stored a full copy of all reports and compared against every older copy. Memory and cost grew for the whole session.This PR moves the logic into a small
UnreadIndicatorUpdatercomponent that renders nothing:useOnyxand takes the current report ID fromuseCurrentReportIDState. React Compiler caches the count, so it is only redone when one of its inputs changes, and no old copies are kept.getUnreadReportsForUnreadIndicatoris now a pure function that takes all its data as arguments. The module-level Onyx subscriptions, thememoizecache, the debounce and the navigation and app-state listeners are removed.Expensify.tsxonce the splash screen is hidden, which replaces the lazyload.tsimport. On Android it rendersnull, as before there is no tab title or badge to update.There is no user-facing behavior change.
Measured (heavy test account with 4,061 reports, production web build, 4x CPU throttle, 200 simulated updates to one report,
mainand this PR on the same day):main, the unread check costs about 0.9 ms more with every update, with no limit: 26 ms at the start, 187 ms after 200 updates. The whole update goes from 519 ms to 678 ms.mainvs 508 ms with this PR, 170 ms (25%) less per update. The unread check alone drops from 187 ms to 13 ms (93% less), and the gap keeps growing as the session goes on.Fixed Issues
$#105827
PROPOSAL:
Tests
npx jest tests/ui/UnreadIndicatorUpdaterTest.tsxand verify all tests pass.Offline tests
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)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