From 2efff151f9022e0390becae5880f55d3c31cd25d Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Fri, 18 Aug 2023 12:51:20 +0100 Subject: [PATCH] Make sure to get correct total for optimistic paid message --- src/libs/ReportUtils.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 77507164fe03..84c50fcb56f3 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1803,6 +1803,7 @@ function buildOptimisticExpenseReport(chatReportID, policyID, payeeAccountID, to } /** + * @param {String} iouReportID - the report ID of the IOU report the action belongs to * @param {String} type - IOUReportAction type. Can be oneOf(create, decline, cancel, pay, split) * @param {Number} total - IOU total in cents * @param {String} comment - IOU comment @@ -1811,8 +1812,8 @@ function buildOptimisticExpenseReport(chatReportID, policyID, payeeAccountID, to * @param {Boolean} isSettlingUp - Whether we are settling up an IOU * @returns {Array} */ -function getIOUReportActionMessage(type, total, comment, currency, paymentType = '', isSettlingUp = false) { - const amount = CurrencyUtils.convertToDisplayString(total, currency); +function getIOUReportActionMessage(iouReportID, type, total, comment, currency, paymentType = '', isSettlingUp = false) { + let amount = CurrencyUtils.convertToDisplayString(total, currency); let paymentMethodMessage; switch (paymentType) { case CONST.IOU.PAYMENT_TYPE.ELSEWHERE: @@ -1838,6 +1839,7 @@ function getIOUReportActionMessage(type, total, comment, currency, paymentType = iouMessage = `deleted the ${amount} request${comment && ` for ${comment}`}`; break; case CONST.IOU.REPORT_ACTION_TYPE.PAY: + amount = CurrencyUtils.convertToDisplayString(getMoneyRequestTotal(getReport(iouReportID)), currency); iouMessage = isSettlingUp ? `paid ${amount}${paymentMethodMessage}` : `sent ${amount}${comment && ` for ${comment}`}${paymentMethodMessage}`; break; default: @@ -1931,7 +1933,7 @@ function buildOptimisticIOUReportAction( avatar: lodashGet(currentUserPersonalDetails, 'avatar', UserUtils.getDefaultAvatar(currentUserAccountID)), isAttachment: false, originalMessage, - message: getIOUReportActionMessage(type, amount, comment, currency, paymentType, isSettlingUp), + message: getIOUReportActionMessage(iouReportID, type, amount, comment, currency, paymentType, isSettlingUp), person: [ { style: 'strong',