Skip to content
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

Make sure to get correct total for optimistic paid message #25474

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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);
mountiny marked this conversation as resolved.
Show resolved Hide resolved
mountiny marked this conversation as resolved.
Show resolved Hide resolved
iouMessage = isSettlingUp ? `paid ${amount}${paymentMethodMessage}` : `sent ${amount}${comment && ` for ${comment}`}${paymentMethodMessage}`;
break;
default:
Expand Down Expand Up @@ -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',
Expand Down
Loading