Skip to content

Commit

Permalink
Merge pull request #50372 from bernhardoj/fix/49993-incorrect-money-r…
Browse files Browse the repository at this point in the history
…equest-text-preview

Fix the money request preview text shows description instead of merchant
  • Loading branch information
yuwenmemon authored Oct 10, 2024
2 parents d1feccc + fc87876 commit 36a810f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3358,7 +3358,7 @@ function getTransactionReportName(reportAction: OnyxEntry<ReportAction | Optimis
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)) ?? '';
const comment = TransactionUtils.getMerchantOrDescription(transaction);
if (ReportActionsUtils.isTrackExpenseAction(reportAction)) {
return Localize.translateLocal('iou.threadTrackReportName', {formattedAmount, comment});
}
Expand Down Expand Up @@ -3409,7 +3409,7 @@ function getReportPreviewMessage(

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) ?? ''});
return Localize.translateLocal('iou.didSplitAmount', {formattedAmount, comment: TransactionUtils.getMerchantOrDescription(linkedTransaction)});
}
}

Expand All @@ -3431,7 +3431,7 @@ function getReportPreviewMessage(

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) ?? ''});
return Localize.translateLocal('iou.trackedAmount', {formattedAmount, comment: TransactionUtils.getMerchantOrDescription(linkedTransaction)});
}
}

Expand Down Expand Up @@ -3507,7 +3507,7 @@ function getReportPreviewMessage(
linkedTransaction = getLinkedTransaction(iouReportAction);
}

let comment = !isEmptyObject(linkedTransaction) ? TransactionUtils.getDescription(linkedTransaction) : undefined;
let comment = !isEmptyObject(linkedTransaction) ? TransactionUtils.getMerchantOrDescription(linkedTransaction) : undefined;
if (!isEmptyObject(originalReportAction) && ReportActionsUtils.isReportPreviewAction(originalReportAction) && ReportActionsUtils.getNumberOfMoneyRequests(originalReportAction) !== 1) {
comment = undefined;
}
Expand Down Expand Up @@ -7288,7 +7288,7 @@ function getIOUReportActionDisplayMessage(reportAction: OnyxEntry<ReportAction>,
}
return Localize.translateLocal(translationKey, {
formattedAmount,
comment: TransactionUtils.getDescription(transaction) ?? '',
comment: TransactionUtils.getMerchantOrDescription(transaction),
});
}

Expand Down
5 changes: 5 additions & 0 deletions src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ function getMerchant(transaction: OnyxInputOrEntry<Transaction>): string {
return transaction?.modifiedMerchant ? transaction.modifiedMerchant : transaction?.merchant ?? '';
}

function getMerchantOrDescription(transaction: OnyxEntry<Transaction>) {
return !isMerchantMissing(transaction) ? getMerchant(transaction) : getDescription(transaction);
}

/**
* Return the reimbursable value. Defaults to true to match BE logic.
*/
Expand Down Expand Up @@ -1096,6 +1100,7 @@ export {
getOriginalCurrency,
getOriginalAmount,
getMerchant,
getMerchantOrDescription,
getMCCGroup,
getCreated,
getFormattedCreated,
Expand Down

0 comments on commit 36a810f

Please sign in to comment.