perf: getBankAccountRoute usage optimization#65845
Conversation
|
@srikarparsi 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] |
mountiny
left a comment
There was a problem hiding this comment.
Changes look good to me
| onPress={confirm} | ||
| enablePaymentsRoute={ROUTES.IOU_SEND_ENABLE_PAYMENTS} | ||
| addBankAccountRoute={bankAccountRoute} | ||
| chatReport={chatReport} |
There was a problem hiding this comment.
It looks like SettlementButton uses chatReportID to fetch the chat report via useOnyx. It does not use this chatReport prop. The chat report won’t be available here because chatReportID is not passed to this component.
| onSuccessfulKYC={() => Navigation.navigate(ROUTES.ENABLE_PAYMENTS)} | ||
| enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS} | ||
| addBankAccountRoute={ROUTES.BANK_ACCOUNT_PERSONAL} | ||
| chatReport={report} |
There was a problem hiding this comment.
We are replacing a static route here. I think we should match this with the chatReportID passed here.
However, the function getBankAccountRoute does not seem to ever return the route being replaced here.
| chatReport={report} | |
| chatReport={targetReport} |
There was a problem hiding this comment.
The old route was ROUTES.BANK_ACCOUNT_PERSONAL. The function getBankAccountRoute does not return this route. Is this okay?
There was a problem hiding this comment.
hmm good point, I have to dig a little bit since I haven't worked on this PR originally
There was a problem hiding this comment.
@c3024 I couldn't figure out the proper condition to incorporate this path into getBankAccountRoute. Instead, I brought back the addBankAccountRoute param as optional, so if it's defined, it will use it in first place. What do you think about this?
|
Since Marta is OOO this week I took it over. @c3024 I addressed your comments, could you take a look again? |
| /** Chat report for calculating bank account routes */ | ||
| chatReport?: OnyxEntry<Report>; |
There was a problem hiding this comment.
| /** Chat report for calculating bank account routes */ | |
| chatReport?: OnyxEntry<Report>; |
This is not required because chatReportID is a prop for SettlementButton and it fetches report with useOnyx.
| confirmApproval={confirmApproval} | ||
| enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS} | ||
| addBankAccountRoute={bankAccountRoute} | ||
| chatReport={chatReport} |
There was a problem hiding this comment.
| chatReport={chatReport} |
We are passing chatReportID. This is enough for the report inside the SettlementButton.
| onPress={confirmPayment} | ||
| enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS} | ||
| addBankAccountRoute={bankAccountRoute} | ||
| chatReport={chatReport} |
There was a problem hiding this comment.
Not required because the prop chatReportID is already available.
| chatReport={chatReport} |
|
There are conflicts too. |
|
@c3024 done, thanks for spotting those 🙏 |
b1eca75 to
57bfb32
Compare
| onSuccessfulKYC={() => Navigation.navigate(ROUTES.ENABLE_PAYMENTS)} | ||
| enablePaymentsRoute={ROUTES.ENABLE_PAYMENTS} | ||
| addBankAccountRoute={ROUTES.BANK_ACCOUNT_PERSONAL} | ||
| addDebitCardRoute={ROUTES.SETTINGS_ADD_DEBIT_CARD} |
There was a problem hiding this comment.
We should retain this, right?
| addDebitCardRoute={ROUTES.SETTINGS_ADD_DEBIT_CARD} | |
| addBankAccountRoute={ROUTES.BANK_ACCOUNT_PERSONAL} | |
| addDebitCardRoute={ROUTES.SETTINGS_ADD_DEBIT_CARD} |
| pressOnEnter | ||
| onPress={submitAndNavigateToNextPage} | ||
| enablePaymentsRoute={ROUTES.IOU_SEND_ENABLE_PAYMENTS} | ||
| addBankAccountRoute={bankAccountRoute} |
There was a problem hiding this comment.
I missed this last time. SettlementButton does not get chatReportID prop here so it cannot know the correct route. We can pass the reportID from IOURequestStepAmount to MoneyRequestAmountForm and then to SettlementButton.
|
@c3024 thanks, updated the branch with your suggestions |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppbankAndroid.movAndroid: mWeb ChromebankAndroidmWeb.moviOS: HybridAppbankiOS.moviOS: mWeb SafaribankiOSmWeb.movMacOS: Chrome / SafaribankChrome1.movbankChrome2.movMacOS: DesktopbankDesktop.mov |
mountiny
left a comment
There was a problem hiding this comment.
Going to move this one ahead as its very exciting perf improvement!
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.1.83-0 🚀
|
|
🚀 Deployed to production by https://github.com/cristipaval in version: 9.1.83-5 🚀
|
Explanation of Change
getBankAccountRoutefunction itself is fast in a single call (2-5ms) but we call it so many times that its combined time grows extremely. This PR makes a single call to this function instead of precomputing the route for all items.Fixed Issues
$ #65868
Tests
Case 1:
Case 2 (Precondition: User has submitted a personal expense report that needs reimbursement):
Case 3: (Precondition: User has received an invoice in an individual invoice room)
Offline tests
Same as Tests.
QA Steps
Same as Tests.
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))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
Nagranie.z.ekranu.2025-07-10.o.16.30.24.mov
Android: mWeb Chrome
Nagranie.z.ekranu.2025-07-10.o.16.31.59.mov
iOS: Native
Nagranie.z.ekranu.2025-07-10.o.15.54.00.mov
iOS: mWeb Safari
Nagranie.z.ekranu.2025-07-10.o.16.09.29.mov
MacOS: Chrome / Safari
Nagranie.z.ekranu.2025-07-10.o.16.20.08.mov
MacOS: Desktop
Nagranie.z.ekranu.2025-07-10.o.16.27.41.mov
Measurements
Before:
After: