diff --git a/src/CONST.ts b/src/CONST.ts index 70db2e661056..a977b164e8bf 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -839,6 +839,7 @@ const CONST = { SHARE: 'SHARE', // OldDot Action STRIPE_PAID: 'STRIPEPAID', // OldDot Action SUBMITTED: 'SUBMITTED', + SUBMITTED_AND_CLOSED: 'SUBMITTEDCLOSED', TAKE_CONTROL: 'TAKECONTROL', // OldDot Action TASK_CANCELLED: 'TASKCANCELLED', TASK_COMPLETED: 'TASKCOMPLETED', diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index b0c48eb37eb7..bf1e5a894b7c 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -670,8 +670,16 @@ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails lastMessageTextFromReport = ReportUtils.formatReportLastMessageText(TaskUtils.getTaskReportActionMessage(lastReportAction).text); } else if (ReportActionUtils.isCreatedTaskReportAction(lastReportAction)) { lastMessageTextFromReport = TaskUtils.getTaskCreatedMessage(lastReportAction); - } else if (ReportActionUtils.isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED)) { - lastMessageTextFromReport = ReportUtils.getIOUSubmittedMessage(lastReportAction); + } else if ( + ReportActionUtils.isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED) || + ReportActionUtils.isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED) + ) { + const wasSubmittedViaHarvesting = ReportActionUtils.getOriginalMessage(lastReportAction)?.harvesting ?? false; + if (wasSubmittedViaHarvesting) { + lastMessageTextFromReport = ReportUtils.getReportAutomaticallySubmittedMessage(lastReportAction); + } else { + lastMessageTextFromReport = ReportUtils.getIOUSubmittedMessage(lastReportAction); + } } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED) { lastMessageTextFromReport = ReportUtils.getIOUApprovedMessage(lastReportAction); } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.FORWARDED) { diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index bd49e1bb60ac..76d52e75b0f4 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -163,6 +163,10 @@ function isSubmittedAction(reportAction: OnyxInputOrEntry): report return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED); } +function isSubmittedAndClosedAction(reportAction: OnyxInputOrEntry): reportAction is ReportAction { + return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED); +} + function isApprovedAction(reportAction: OnyxInputOrEntry): reportAction is ReportAction { return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.APPROVED); } @@ -1839,6 +1843,7 @@ export { isTripPreview, isWhisperAction, isSubmittedAction, + isSubmittedAndClosedAction, isApprovedAction, isForwardedAction, isWhisperActionTargetedToOthers, diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 2dc4df7aca4a..f5ed8f606c98 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3776,7 +3776,10 @@ function getReportName( } const parentReportActionMessage = ReportActionsUtils.getReportActionMessage(parentReportAction); - if (ReportActionsUtils.isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED)) { + if ( + ReportActionsUtils.isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED) || + ReportActionsUtils.isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED) + ) { return getIOUSubmittedMessage(parentReportAction); } if (parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.FORWARDED) { @@ -4505,7 +4508,12 @@ function buildOptimisticExpenseReport( } function getFormattedAmount(reportAction: ReportAction) { - if (!ReportActionsUtils.isSubmittedAction(reportAction) && !ReportActionsUtils.isForwardedAction(reportAction) && !ReportActionsUtils.isApprovedAction(reportAction)) { + if ( + !ReportActionsUtils.isSubmittedAction(reportAction) && + !ReportActionsUtils.isForwardedAction(reportAction) && + !ReportActionsUtils.isApprovedAction(reportAction) && + !ReportActionsUtils.isSubmittedAndClosedAction(reportAction) + ) { return ''; } const originalMessage = ReportActionsUtils.getOriginalMessage(reportAction); @@ -4513,11 +4521,13 @@ function getFormattedAmount(reportAction: ReportAction) { return formattedAmount; } -function getReportAutomaticallySubmittedMessage(reportAction: ReportAction) { +function getReportAutomaticallySubmittedMessage( + reportAction: ReportAction | ReportAction, +) { return Localize.translateLocal('iou.automaticallySubmittedAmount', {formattedAmount: getFormattedAmount(reportAction)}); } -function getIOUSubmittedMessage(reportAction: ReportAction) { +function getIOUSubmittedMessage(reportAction: ReportAction | ReportAction) { return Localize.translateLocal('iou.submittedAmount', {formattedAmount: getFormattedAmount(reportAction)}); } diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 8b1dd967c1c0..f66972433a28 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -439,7 +439,10 @@ const ContextMenuActions: ContextMenuAction[] = [ setClipboardMessage(CONST.ACTIONABLE_TRACK_EXPENSE_WHISPER_MESSAGE); } else if (ReportActionsUtils.isRenamedAction(reportAction)) { setClipboardMessage(ReportActionsUtils.getRenamedAction(reportAction)); - } else if (ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED)) { + } else if ( + ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED) || + ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED) + ) { const displayMessage = ReportUtils.getIOUSubmittedMessage(reportAction); Clipboard.setString(displayMessage); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED) { diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 3ed0841686a1..2e7260d2e384 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -627,7 +627,10 @@ function ReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE) { children = ; - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.SUBMITTED)) { + } else if ( + ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.SUBMITTED) || + ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED) + ) { const wasSubmittedViaHarvesting = ReportActionsUtils.getOriginalMessage(action)?.harvesting ?? false; if (wasSubmittedViaHarvesting) { children = ( diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 33d2cf6e6866..3ff61dfe0eba 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -594,6 +594,7 @@ type OriginalMessageMap = { [CONST.REPORT.ACTIONS.TYPE.SHARE]: never; [CONST.REPORT.ACTIONS.TYPE.STRIPE_PAID]: never; [CONST.REPORT.ACTIONS.TYPE.SUBMITTED]: OriginalMessageSubmitted; + [CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED]: OriginalMessageSubmitted; [CONST.REPORT.ACTIONS.TYPE.TASK_CANCELLED]: never; [CONST.REPORT.ACTIONS.TYPE.TASK_COMPLETED]: never; [CONST.REPORT.ACTIONS.TYPE.TASK_EDITED]: never;