perf: Optimize MoneyRequestReportTransactionItem#82560
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.
|
|
🚧 @rlinoz has triggered a test Expensify/App build. You can view the workflow run here. |
This comment has been minimized.
This comment has been minimized.
|
🚧 @rlinoz 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! 🧪🧪
|
There was a problem hiding this comment.
Thanks @rlinoz! Left couple of (mostly tiny) comments.
| }, [sortedTransactions, currentGroupBy, report?.reportID, report?.currency, localeCompare, shouldShowGroupedTransactions]); | ||
| }, [sortedTransactions, currentGroupBy, report, localeCompare, shouldShowGroupedTransactions]); |
There was a problem hiding this comment.
Original code used entire report but defined only a few object properties as dependency. Nice catch, but could've that specification been done on purpose?
There was a problem hiding this comment.
oh I changed this because lint was complaining....not sure I will investiagte.
There was a problem hiding this comment.
Rolled this back, this is the explanation 1431f58#diff-fdae540f324f25f7a8b7f7c44ebf5eb8681a7cef16b937fd24ef2546618561baR250-R302 not sure why we removed that comment though.
| /> | ||
| {shouldMountPreview && ( | ||
| <ReceiptPreview | ||
| source={previewSource} | ||
| hovered={hovered} | ||
| isEReceipt={!!isEReceipt} | ||
| transactionItem={transactionItem} | ||
| /> |
There was a problem hiding this comment.
What would happen if we simply use pure hovered instead of adding shouldMountPreview?
There was a problem hiding this comment.
On re-hover we would have to mount the component again, not a huge deal though. I don't mind changing if you think the extra logic is not worth it.
There was a problem hiding this comment.
Correct me if I traced that call tree wrong, but looks like ReceiptPreview renders conditionally too based on shouldShow (derived value from hovered).
App/src/components/TransactionItemRow/ReceiptPreview/index.tsx
Lines 92 to 98 in c835e8d
Wonder what's the impact of this trade-off in rendering. How did that influence your measurements?
There was a problem hiding this comment.
interesting, I didn't really take a look at the ReceiptPreview component, but not mounting it right away almos halved the time of receiptcell rendering in dev
|
@ChavdaSachin 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] |
|
Ignoring lint for now, I would like to not introduce a change regarding |
|
Reviewing ♻️ |
|
NAB: |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2026-02-20.at.4.06.23.PM.movAndroid: mWeb ChromeScreen.Recording.2026-02-20.at.4.13.42.PM.moviOS: HybridAppScreen.Recording.2026-02-20.at.12.48.31.PM.moviOS: mWeb SafariScreen.Recording.2026-02-20.at.1.09.00.PM.movMacOS: Chrome / SafariScreen.Recording.2026-02-18.at.10.22.30.PM.mov |
|
No product review needed |
|
@youssef-lr 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] |
marcaaron
left a comment
There was a problem hiding this comment.
Looks pretty good to me!
| handleOnPress(transaction.transactionID); | ||
| }} | ||
| accessibilityLabel={translate('iou.viewDetails')} | ||
| sentryLabel="MoneyRequestReportTransactionItem-ViewDetails" |
There was a problem hiding this comment.
Mostly curious as this is the first time I've seen it - but what does this allow us to track exactly? And how do we query for it?
There was a problem hiding this comment.
it tracks the click interaction time for each pressable, here is how it looks currently in Sentry:
We have an issue to clean up the naming though.
There was a problem hiding this comment.
This should be a const though, updated.
| })); | ||
| }, [newTransactions, sortBy, sortOrder, transactions, localeCompare, report]); | ||
| return [...transactions].sort((a, b) => compareValues(getTransactionValue(a, sortBy, report), getTransactionValue(b, sortBy, report), sortOrder, sortBy, localeCompare, true)); | ||
| }, [sortBy, sortOrder, transactions, localeCompare, report]); |
There was a problem hiding this comment.
NAB, was this auto-linted? I feel it hurt the readability a bit, but won't argue with an auto-linter.
There was a problem hiding this comment.
What exactly? I removed the map so it became a single function call over the array.
You think it looks better if the sort is in the next line? I can try that!
There was a problem hiding this comment.
Ok, I tried moving it to a different line and prettier didn't like it 😄
| return [...transactions].sort((a, b) => compareValues(getTransactionValue(a, sortBy, report), getTransactionValue(b, sortBy, report), sortOrder, sortBy, localeCompare, true)); | ||
| }, [sortBy, sortOrder, transactions, localeCompare, report]); | ||
|
|
||
| const highlightedTransactionIDs = useMemo(() => new Set(newTransactions.map(({transactionID}) => transactionID)), [newTransactions]); |
There was a problem hiding this comment.
I am new to React compiler, but would it know to memoize this if we did not use the useMemo?
There was a problem hiding this comment.
Good catch, react should auto memoize this.
There was a problem hiding this comment.
React Compiler is not really working for this component yet though
src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx:269:8
React Compiler has skipped optimizing this component because one or more React ESLint rules were disabled. React Compiler only works when your components follow all the rules of React, disabling them may result in unexpected or incorrect behavior
src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx:313:8
React Compiler has skipped optimizing this component because one or more React ESLint rules were disabled. React Compiler only works when your components follow all the rules of React, disabling them may result in unexpected or incorrect behavior
There was a problem hiding this comment.
Oh interesting. I wonder which rules we were not following. Anyway NAB because the result is the same for now.
| const bgActiveStyles = useMemo(() => { | ||
| if (!isSelected || !shouldHighlightItemWhenSelected) { | ||
| return []; | ||
| return EMPTY_ACTIVE_STYLE; |
There was a problem hiding this comment.
Does it make a difference? 🤔
There was a problem hiding this comment.
In the grand scheme of things, definitely no 😅
There was a problem hiding this comment.
Let me know if you think I should remove it.
There was a problem hiding this comment.
Yeah if it's not really doing much then it's easier to return an empty array, but also not a huge deal.
| })); | ||
| }, [newTransactions, sortBy, sortOrder, transactions, localeCompare, report]); | ||
| return [...transactions].sort((a, b) => compareValues(getTransactionValue(a, sortBy, report), getTransactionValue(b, sortBy, report), sortOrder, sortBy, localeCompare, true)); | ||
| }, [sortBy, sortOrder, transactions, localeCompare, report]); |
|
🚧 @rlinoz 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/rlinoz in version: 9.3.26-0 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 9.3.26-8 🚀
|
Explanation of Change
A few updates on how we handle the
MoneyRequestReportTransactionItemso we have less re-renders or items render faster.Fixed Issues
$ #82717
PROPOSAL:
Tests
Offline tests
QA Steps
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