[No QA] perf: replace reportsSelector with useReportAttributes hook#82551
Conversation
Remove the reportsSelector that triggered expensive deepEqual comparisons on every Onyx update cycle. The new useReportAttributes hook reads the derived value directly, allowing useOnyx to use shallowEqual (O(1)) instead of deepEqual (O(n)) for change detection.
|
@hungvu193 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] |
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.
|
mountiny
left a comment
There was a problem hiding this comment.
@TMisiukiewicz Can you please add tests? is the reportsSelector used in other places or it should be removed?
|
@mountiny can you reassign this one please? I'll handle the other one 🙏 |
|
@mountiny we removed the Fixed the lint changed check, added tests and comment in the hook ✅ |
a58e684
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2026-02-16.at.10.27.57.PM.mov |
mountiny
left a comment
There was a problem hiding this comment.
Thank you! Cristi approved before so I will merge
|
✋ 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.3.21-0 🚀
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.3.21-4 🚀
|
Explanation of Change
Replace
reportsSelectorwith a newuseReportAttributeshook to avoid expensivedeepEqualcomparisons on every Onyx update cycle. The selector defeats its own purpose - they are meant to narrow down data to a small subset, but here it simply extracts one massive property containing thousands of entries, providing no meaningful reduction in comparison cost.The new
useReportAttributeshook readsONYXKEYS.DERIVED.REPORT_ATTRIBUTESdirectly without a selector. This allowsuseOnyxto use cheaper shallow equal.It should improve some of the metrics in the app, as an example, when testing it with sending a message, this change saves around 200ms on every message.
Fixed Issues
$ #80560
Improves #77176
PROPOSAL:
Tests
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
no qa tests needed
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand 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