diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 330d9d6ef61d..73b04742878a 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -657,10 +657,11 @@ function isSearchStringMatchUserDetails(personalDetail: PersonalDetails, searchV * Get the last message text from the report directly or from other sources for special cases. */ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails: Partial | null, policy?: OnyxEntry): string { - const lastReportAction = visibleReportActionItems[report?.reportID ?? '-1'] ?? null; + const reportID = report?.reportID ?? '-1'; + const lastReportAction = visibleReportActionItems[reportID] ?? null; // some types of actions are filtered out for lastReportAction, in some cases we need to check the actual last action - const lastOriginalReportAction = lastReportActions[report?.reportID ?? '-1'] ?? null; + const lastOriginalReportAction = lastReportActions[reportID] ?? null; let lastMessageTextFromReport = ''; if (ReportUtils.isArchivedRoom(report)) { @@ -720,8 +721,10 @@ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails lastMessageTextFromReport = ReportUtils.formatReportLastMessageText(TaskUtils.getTaskReportActionMessage(lastReportAction).text); } else if (ReportActionUtils.isCreatedTaskReportAction(lastReportAction)) { lastMessageTextFromReport = TaskUtils.getTaskCreatedMessage(lastReportAction); - } else if (ReportActionUtils.isApprovedOrSubmittedReportAction(lastReportAction)) { - lastMessageTextFromReport = ReportActionUtils.getReportActionMessageText(lastReportAction); + } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) { + lastMessageTextFromReport = ReportUtils.getIOUSubmittedMessage(reportID); + } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED) { + lastMessageTextFromReport = ReportUtils.getIOUApprovedMessage(reportID); } return lastMessageTextFromReport || (report?.lastMessageText ?? ''); diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index fb3bebd75274..0a333b2f1f39 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4002,11 +4002,19 @@ function buildOptimisticExpenseReport(chatReportID: string, policyID: string, pa return expenseReport; } -function getIOUSubmittedMessage(reportID: string) { +function getFormattedAmount(reportID: string) { const report = getReportOrDraftReport(reportID); const linkedReport = isChatThread(report) ? getParentReport(report) : report; const formattedAmount = CurrencyUtils.convertToDisplayString(Math.abs(linkedReport?.total ?? 0), linkedReport?.currency); - return Localize.translateLocal('iou.submittedAmount', {formattedAmount}); + return formattedAmount; +} + +function getIOUSubmittedMessage(reportID: string) { + return Localize.translateLocal('iou.submittedAmount', {formattedAmount: getFormattedAmount(reportID)}); +} + +function getIOUApprovedMessage(reportID: string) { + return Localize.translateLocal('iou.approvedAmount', {amount: getFormattedAmount(reportID)}); } /** @@ -7167,6 +7175,7 @@ export { getGroupChatName, getIOUReportActionDisplayMessage, getIOUReportActionMessage, + getIOUApprovedMessage, getIOUSubmittedMessage, getIcons, getIconsForParticipants, diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 218c382fd776..1fa6766d77c3 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -400,6 +400,9 @@ const ContextMenuActions: ContextMenuAction[] = [ } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) { const displayMessage = ReportUtils.getIOUSubmittedMessage(reportID); Clipboard.setString(displayMessage); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED) { + const displayMessage = ReportUtils.getIOUApprovedMessage(reportID); + Clipboard.setString(displayMessage); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) { Clipboard.setString(Localize.translateLocal('iou.heldExpense')); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) { diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index e732c5793f96..9135e494794e 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -621,6 +621,8 @@ function ReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD_COMMENT) {