diff --git a/src/components/ReportActionItem/ReportPreview.js b/src/components/ReportActionItem/ReportPreview.js index d5d85df5e7ee..0ba0a1c4099f 100644 --- a/src/components/ReportActionItem/ReportPreview.js +++ b/src/components/ReportActionItem/ReportPreview.js @@ -95,6 +95,9 @@ const defaultProps = { function ReportPreview(props) { const managerID = props.iouReport.managerID || props.action.actorAccountID || 0; const isCurrentUserManager = managerID === lodashGet(props.session, 'accountID'); + const moneyRequestCount = lodashGet(props.action, 'childMoneyRequestCount', 0); + const moneyRequestComment = lodashGet(props.action, 'childLastMoneyRequestComment', ''); + const showComment = moneyRequestComment || moneyRequestCount > 1; const reportTotal = ReportUtils.getMoneyRequestTotal(props.iouReport); let displayAmount; if (reportTotal) { @@ -148,6 +151,15 @@ function ReportPreview(props) { )} + {showComment && ( + + + + {moneyRequestCount > 1 ? props.translate('iou.requestCount', {count: moneyRequestCount}) : moneyRequestComment} + + + + )} {shouldShowSettlementButton && ( `${formattedAmount} request${comment ? ` for ${comment}` : ''}`, threadSentMoneyReportName: ({formattedAmount, comment}) => `${formattedAmount} sent${comment ? ` for ${comment}` : ''}`, + requestCount: ({count}) => `${count} requests`, error: { invalidSplit: 'Split amounts do not equal total amount', other: 'Unexpected error, please try again later', diff --git a/src/languages/es.js b/src/languages/es.js index 4cdfc4e32f14..5f33be6c3e6a 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -401,6 +401,7 @@ export default { pendingConversionMessage: 'El total se actualizará cuando estés online', threadRequestReportName: ({formattedAmount, comment}) => `Solicitud de ${formattedAmount}${comment ? ` para ${comment}` : ''}`, threadSentMoneyReportName: ({formattedAmount, comment}) => `${formattedAmount} enviado${comment ? ` para ${comment}` : ''}`, + requestCount: ({count}) => `${count} solicitudes`, error: { invalidSplit: 'La suma de las partes no equivale al monto total', other: 'Error inesperado, por favor inténtalo más tarde', diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index e3b6cb2ccc52..e46f1b39971e 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1852,10 +1852,11 @@ function buildOptimisticIOUReportAction( * * @param {Object} chatReport * @param {Object} iouReport + * @param {String} [comment] - User comment for the IOU. * * @returns {Object} */ -function buildOptimisticReportPreview(chatReport, iouReport) { +function buildOptimisticReportPreview(chatReport, iouReport, comment = '') { const message = getReportPreviewMessage(iouReport); return { reportActionID: NumberUtils.rand64(), @@ -1876,6 +1877,8 @@ function buildOptimisticReportPreview(chatReport, iouReport) { created: DateUtils.getDBTime(), accountID: iouReport.managerID || 0, actorAccountID: iouReport.managerID || 0, + childMoneyRequestCount: 1, + childLastMoneyRequestComment: comment, }; } @@ -1884,10 +1887,11 @@ function buildOptimisticReportPreview(chatReport, iouReport) { * * @param {Object} iouReport * @param {Object} reportPreviewAction + * @param {String} [comment] - User comment for the IOU. * * @returns {Object} */ -function updateReportPreview(iouReport, reportPreviewAction) { +function updateReportPreview(iouReport, reportPreviewAction, comment = '') { const message = getReportPreviewMessage(iouReport, reportPreviewAction); return { ...reportPreviewAction, @@ -1900,6 +1904,8 @@ function updateReportPreview(iouReport, reportPreviewAction) { type: CONST.REPORT.MESSAGE.TYPE.COMMENT, }, ], + childLastMoneyRequestComment: comment || reportPreviewAction.childLastMoneyRequestComment, + childMoneyRequestCount: reportPreviewAction.childMoneyRequestCount + 1, }; } diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 45fcd35eb839..f2c2f75e06dc 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -399,9 +399,9 @@ function requestMoney(report, amount, currency, payeeEmail, payeeAccountID, part let reportPreviewAction = isNewIOUReport ? null : ReportActionsUtils.getReportPreviewAction(chatReport.reportID, iouReport.reportID); if (reportPreviewAction) { - reportPreviewAction = ReportUtils.updateReportPreview(iouReport, reportPreviewAction); + reportPreviewAction = ReportUtils.updateReportPreview(iouReport, reportPreviewAction, comment); } else { - reportPreviewAction = ReportUtils.buildOptimisticReportPreview(chatReport, iouReport); + reportPreviewAction = ReportUtils.buildOptimisticReportPreview(chatReport, iouReport, comment); } // STEP 5: Build Onyx Data @@ -860,6 +860,9 @@ function deleteMoneyRequest(transactionID, reportAction, isSingleTransactionView }); updatedReportPreviewAction.message[0].text = messageText; updatedReportPreviewAction.message[0].html = messageText; + if (reportPreviewAction.childMoneyRequestCount > 0) { + updatedReportPreviewAction.childMoneyRequestCount = reportPreviewAction.childMoneyRequestCount - 1; + } } // STEP 5: Build Onyx data