[No QA] perf: avoid full getTransactionDetails per transaction in getBillableAndTaxTotal#91716
Conversation
…er-transaction date formatting
|
@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] |
|
@abdulrahuman5196 I will ask for reassignment in slack for faster review |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2026-05-26.at.18.30.27.mov |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Optimizes getBillableAndTaxTotal by avoiding full getTransactionDetails materialization per transaction, reducing unnecessary formatting/work for large expense reports.
Changes:
- Replace
getTransactionDetails()usage with direct accessors (getBillable,getTaxAmount,getCurrency,getTransactionAmount). - Hoist invariant
reportCurrencyoutside the loop and skip deleted/empty-impact transactions earlier. - Reduce per-transaction overhead by passing
isFromExpenseReport = truedirectly and short-circuiting when totals won’t change.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| continue; | ||
| } | ||
| const billable = getBillable(transaction); | ||
| // `isFromExpenseReport` is provably true: the early return above guarantees the report is an expense report. |
There was a problem hiding this comment.
I feel that this comment isn't needed
There was a problem hiding this comment.
Ah, ok. it helps to explain why we are passing true directly for isFromExpenseReport
…lable-tax-total-skip-transaction-details
|
🚧 @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.84-0 🚀
Bundle Size Analysis (Sentry): |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.86-0 🚀
Bundle Size Analysis (Sentry): |
|
No help site changes are needed for this PR. This is a pure performance optimization — it replaces @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 needed for this PR. This is an internal performance optimization to @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
getBillableAndTaxTotalonly needs four fields from each transaction (amount,taxAmount,currency,billable) but was callinggetTransactionDetails, which materializes the fullTransactionDetailsobject. That object includes two timezone-aware date formats per transaction (getFormattedCreated+getFormattedPostedDateviaformatWithUTCTimeZone), attendees, waypoints, MCC group, original/converted amount, etc. — all discarded immediately. On an expense report with N transactions this was ~2N date-fns timezone format calls thrown away.Flame graph on iOS showed ~1.2s spent in this function on report-open, dominated by
getFormattedCreated→formatWithUTCTimeZone→toDate/tzParseTimezone/format.Fix:
getTransactionDetailswith the four direct accessors (getBillable,getTaxAmount,getCurrency,getTransactionAmount).reportCurrencyout of the loop (it's an invariant).isFromExpenseReport = truedirectly — the early return above the loop proves the report is an expense report, so the per-transactiongetReportOrDraftReport+isExpenseReportlookups insidegetTransactionDetailsare gone.billableandtaxAmountare falsy — skip currency comparison andgetTransactionAmountfor those rows.This way
getBillableAndTaxTotaltime on a report with 1.6k transactions was reduced from 1.2s to ~5msFixed Issues
$ #91719
PROPOSAL:
Tests
No tests needed, required functions were extracted from
getTransactionDetailsOffline 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
iOS: mWeb Safari
MacOS: Chrome / Safari