Repository navigation
Avoid unnecessary expensive call to getTransactionDetails #45529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2d012da
f2a450d
e99e114
59c7221
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2958,16 +2958,17 @@ function getTransactionReportName(reportAction: OnyxEntry<ReportAction | Optimis | |
| return Localize.translateLocal('iou.fieldPending'); | ||
| } | ||
|
|
||
| const transactionDetails = getTransactionDetails(transaction); | ||
| if (ReportActionsUtils.isSentMoneyReportAction(reportAction)) { | ||
| return getIOUReportActionDisplayMessage(reportAction as ReportAction, transaction); | ||
| } | ||
|
|
||
| const formattedAmount = CurrencyUtils.convertToDisplayString(transactionDetails?.amount ?? 0, transactionDetails?.currency) ?? ''; | ||
| const comment = (!TransactionUtils.isMerchantMissing(transaction) ? transactionDetails?.merchant : transactionDetails?.comment) ?? ''; | ||
| const report = getReportOrDraftReport(transaction?.reportID); | ||
| const amount = TransactionUtils.getAmount(transaction, !isEmptyObject(report) && isExpenseReport(report)) ?? 0; | ||
| const formattedAmount = CurrencyUtils.convertToDisplayString(amount, TransactionUtils.getCurrency(transaction)) ?? ''; | ||
| const comment = (!TransactionUtils.isMerchantMissing(transaction) ? TransactionUtils.getMerchant(transaction) : TransactionUtils.getDescription(transaction)) ?? ''; | ||
| if (ReportActionsUtils.isTrackExpenseAction(reportAction)) { | ||
| return Localize.translateLocal('iou.threadTrackReportName', {formattedAmount, comment}); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we also move this block up?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we? it relies on the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets explore this later if its possible? |
||
| if (ReportActionsUtils.isSentMoneyReportAction(reportAction)) { | ||
| return getIOUReportActionDisplayMessage(reportAction as ReportAction, transaction); | ||
| } | ||
| return Localize.translateLocal('iou.threadExpenseReportName', {formattedAmount, comment}); | ||
| } | ||
|
|
||
|
|
@@ -3013,9 +3014,9 @@ function getReportPreviewMessage( | |
| return Localize.translateLocal('iou.receiptMissingDetails'); | ||
| } | ||
|
|
||
| const transactionDetails = getTransactionDetails(linkedTransaction); | ||
| const formattedAmount = CurrencyUtils.convertToDisplayString(transactionDetails?.amount ?? 0, transactionDetails?.currency); | ||
| return Localize.translateLocal('iou.didSplitAmount', {formattedAmount, comment: transactionDetails?.comment ?? ''}); | ||
| const amount = TransactionUtils.getAmount(linkedTransaction, !isEmptyObject(report) && isExpenseReport(report)) ?? 0; | ||
| const formattedAmount = CurrencyUtils.convertToDisplayString(amount, TransactionUtils.getCurrency(linkedTransaction)) ?? ''; | ||
| return Localize.translateLocal('iou.didSplitAmount', {formattedAmount, comment: TransactionUtils.getDescription(linkedTransaction) ?? ''}); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -3035,9 +3036,9 @@ function getReportPreviewMessage( | |
| return Localize.translateLocal('iou.receiptMissingDetails'); | ||
| } | ||
|
|
||
| const transactionDetails = getTransactionDetails(linkedTransaction); | ||
| const formattedAmount = CurrencyUtils.convertToDisplayString(transactionDetails?.amount ?? 0, transactionDetails?.currency); | ||
| return Localize.translateLocal('iou.trackedAmount', {formattedAmount, comment: transactionDetails?.comment ?? ''}); | ||
| const amount = TransactionUtils.getAmount(linkedTransaction, !isEmptyObject(report) && isExpenseReport(report)) ?? 0; | ||
| const formattedAmount = CurrencyUtils.convertToDisplayString(amount, TransactionUtils.getCurrency(linkedTransaction)) ?? ''; | ||
| return Localize.translateLocal('iou.trackedAmount', {formattedAmount, comment: TransactionUtils.getDescription(linkedTransaction) ?? ''}); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -6403,8 +6404,8 @@ function getIOUReportActionDisplayMessage(reportAction: OnyxEntry<ReportAction>, | |
| return Localize.translateLocal(translationKey, {amount: formattedAmount, payer: ''}); | ||
| } | ||
|
|
||
| const transactionDetails = getTransactionDetails(!isEmptyObject(transaction) ? transaction : undefined); | ||
| const formattedAmount = CurrencyUtils.convertToDisplayString(transactionDetails?.amount ?? 0, transactionDetails?.currency); | ||
| const amount = TransactionUtils.getAmount(transaction, !isEmptyObject(iouReport) && isExpenseReport(iouReport)) ?? 0; | ||
| const formattedAmount = CurrencyUtils.convertToDisplayString(amount, TransactionUtils.getCurrency(transaction)) ?? ''; | ||
| const isRequestSettled = isSettled(originalMessage?.IOUReportID); | ||
| const isApproved = isReportApproved(iouReport); | ||
| if (isRequestSettled) { | ||
|
|
@@ -6426,7 +6427,7 @@ function getIOUReportActionDisplayMessage(reportAction: OnyxEntry<ReportAction>, | |
| } | ||
| return Localize.translateLocal(translationKey, { | ||
| formattedAmount, | ||
| comment: transactionDetails?.comment ?? '', | ||
| comment: TransactionUtils.getDescription(transaction) ?? '', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NAB, should this be called
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess description works for now since we are calling it like this in App |
||
| }); | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.