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

Update optimistic data to match IOU action notification templates, send back additional data needed by Settle Up templates #17090

Merged
merged 8 commits into from
May 2, 2023
10 changes: 3 additions & 7 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1007,10 +1007,6 @@ function buildOptimisticIOUReport(ownerEmail, userEmail, total, chatReportID, cu
*/
function getIOUReportActionMessage(type, total, participants, comment, currency, paymentType = '', isSettlingUp = false) {
const amount = NumberFormatUtils.format(preferredLocale, total / 100, {style: 'currency', currency});
const displayNames = _.map(participants, participant => getDisplayNameForParticipant(participant.login, true));
const who = displayNames.length < 3
? displayNames.join(' and ')
: `${displayNames.slice(0, -1).join(', ')}, and ${_.last(displayNames)}`;
jasperhuangg marked this conversation as resolved.
Show resolved Hide resolved
let paymentMethodMessage;
switch (paymentType) {
case CONST.IOU.PAYMENT_TYPE.EXPENSIFY:
Expand All @@ -1029,10 +1025,10 @@ function getIOUReportActionMessage(type, total, participants, comment, currency,
let iouMessage;
switch (type) {
case CONST.IOU.REPORT_ACTION_TYPE.CREATE:
iouMessage = `Requested ${amount} from ${who}${comment && ` for ${comment}`}`;
iouMessage = `Requested ${amount}${comment && ` for ${comment}`}`;
break;
case CONST.IOU.REPORT_ACTION_TYPE.SPLIT:
iouMessage = `Split ${amount} with ${who}${comment && ` for ${comment}`}`;
iouMessage = `Split ${amount}${comment && ` for ${comment}`}`;
break;
case CONST.IOU.REPORT_ACTION_TYPE.CANCEL:
iouMessage = `Cancelled the ${amount} request${comment && ` for ${comment}`}`;
Expand All @@ -1042,7 +1038,7 @@ function getIOUReportActionMessage(type, total, participants, comment, currency,
break;
case CONST.IOU.REPORT_ACTION_TYPE.PAY:
iouMessage = isSettlingUp
? `Settled up${paymentMethodMessage}`
? `Settled up ${amount}${paymentMethodMessage}`
: `Sent ${amount}${comment && ` for ${comment}`}${paymentMethodMessage}`;
break;
default:
Expand Down
2 changes: 2 additions & 0 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,8 @@ function getPayMoneyRequestParams(chatReport, iouReport, recipient, paymentMetho
chatReportID: chatReport.reportID,
reportActionID: optimisticIOUReportAction.reportActionID,
paymentMethodType,
amount: iouReport.total,
currency: iouReport.currency,
},
optimisticData,
successData,
Expand Down