From e530284a563332c0ec324bde54715538698b877b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Mon, 8 Jul 2024 14:36:15 -0600 Subject: [PATCH 1/5] chore: Refactor getIOUSubmittedMessage and getIOUApprovedMessage functions --- src/libs/ReportUtils.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index bf8ed75f7646..b3b7bce07a9a 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3995,11 +3995,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)}); } /** @@ -7160,6 +7168,7 @@ export { getGroupChatName, getIOUReportActionDisplayMessage, getIOUReportActionMessage, + getIOUApprovedMessage, getIOUSubmittedMessage, getIcons, getIconsForParticipants, From 31466c4ee307c3ba25b8e4070a31116e32aed7ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Mon, 8 Jul 2024 14:37:41 -0600 Subject: [PATCH 2/5] Refactor ContextMenuActions to handle IOU approval action --- src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 8f130a5546d8..8452e22b8eaf 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) { From 6d918f7712f9d5b890670b1d874e09e8ac3b408c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Mon, 8 Jul 2024 14:37:47 -0600 Subject: [PATCH 3/5] Refactor ReportActionItem to handle IOU approval action --- src/pages/home/report/ReportActionItem.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index e732c5793f96..f91718f9cebd 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) { From c404d2945e6cd5eb12861db1cef94e64d9bf4ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Mon, 8 Jul 2024 15:48:33 -0600 Subject: [PATCH 4/5] Refactor ReportActionItem to handle IOU approval action --- src/pages/home/report/ReportActionItem.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index f91718f9cebd..9135e494794e 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -622,7 +622,7 @@ function ReportActionItem({ } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED) { - children = ; + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD_COMMENT) { From 33720c9d28ede9be8ae634203f7d8bfdc0a9f969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez?= Date: Mon, 8 Jul 2024 16:47:15 -0600 Subject: [PATCH 5/5] Refactor getLastMessageTextForReport function to handle IOU approval action --- src/libs/OptionsListUtils.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index f20d27ffdf22..2e3760845136 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -653,10 +653,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)) { @@ -716,8 +717,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 ?? '');