From 6547e8e00b2fc8f33f5c06c1c41510d923bfd473 Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Sun, 29 Sep 2024 19:31:21 -0600 Subject: [PATCH 1/5] Support submitted closed report action --- src/CONST.ts | 1 + src/libs/OptionsListUtils.ts | 2 +- src/libs/ReportUtils.ts | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 4ca9b45f13df..d0fa092cdfa5 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 51db5a693f91..bf85af738f93 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -660,7 +660,7 @@ 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)) { + } else if (ReportActionUtils.isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED) || ReportActionUtils.isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED)) { lastMessageTextFromReport = ReportUtils.getIOUSubmittedMessage(lastReportAction); } else if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.APPROVED) { lastMessageTextFromReport = ReportUtils.getIOUApprovedMessage(lastReportAction); diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 78ebdd92751e..ca971ac5cc7c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4518,11 +4518,11 @@ 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)}); } From 5e70bfde5018da873925a3d9132602d4934caca2 Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Sun, 29 Sep 2024 20:00:24 -0600 Subject: [PATCH 2/5] Make sure action shows correctly and in LHN --- src/libs/ReportActionsUtils.ts | 5 +++++ src/libs/ReportUtils.ts | 2 +- src/pages/home/report/ReportActionItem.tsx | 2 +- src/types/onyx/OriginalMessage.ts | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 15d7728ba35a..daf6d12e6d89 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); } @@ -1860,6 +1864,7 @@ export { isTripPreview, isWhisperAction, isSubmittedAction, + isSubmittedAndClosedAction, isApprovedAction, isForwardedAction, isWhisperActionTargetedToOthers, diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ca971ac5cc7c..6901636c9e4d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4510,7 +4510,7 @@ 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); diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 33664e2a4162..562e113b8e83 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -627,7 +627,7 @@ 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 4572ac26a449..44a9eb2c2bac 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -587,6 +587,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; From 452855ec1d142828657d963d81974fb2eab3d465 Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Sun, 29 Sep 2024 20:35:40 -0600 Subject: [PATCH 3/5] Show correct auto-submitted message in LHN --- src/libs/OptionsListUtils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index bf85af738f93..2fc51b0bc5f0 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -661,7 +661,12 @@ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails } else if (ReportActionUtils.isCreatedTaskReportAction(lastReportAction)) { lastMessageTextFromReport = TaskUtils.getTaskCreatedMessage(lastReportAction); } else if (ReportActionUtils.isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED) || ReportActionUtils.isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED)) { - lastMessageTextFromReport = ReportUtils.getIOUSubmittedMessage(lastReportAction); + 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) { From b195ecaec01a1ae41a0cda3bad5239fb3515590c Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Sun, 29 Sep 2024 20:44:59 -0600 Subject: [PATCH 4/5] Add a few missing cases --- src/libs/ReportUtils.ts | 2 +- src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 6901636c9e4d..9ee89d6499ae 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3781,7 +3781,7 @@ 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) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 371df4db2b3c..57ecb9f9c331 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -439,7 +439,7 @@ 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) { From d4b8396b1e97ba183e9cddf400c0394c502a8e05 Mon Sep 17 00:00:00 2001 From: Alex Beaman Date: Sun, 29 Sep 2024 20:46:15 -0600 Subject: [PATCH 5/5] prettify --- src/libs/OptionsListUtils.ts | 5 ++++- src/libs/ReportUtils.ts | 16 +++++++++++++--- .../report/ContextMenu/ContextMenuActions.tsx | 5 ++++- src/pages/home/report/ReportActionItem.tsx | 5 ++++- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 2fc51b0bc5f0..88068b73d441 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -660,7 +660,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.isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED) || ReportActionUtils.isActionOfType(lastReportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED)) { + } 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); diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 9ee89d6499ae..5867d8f87555 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3781,7 +3781,10 @@ function getReportName( } const parentReportActionMessage = ReportActionsUtils.getReportActionMessage(parentReportAction); - if (ReportActionsUtils.isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED) || ReportActionsUtils.isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED)) { + 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) { @@ -4510,7 +4513,12 @@ function buildOptimisticExpenseReport( } function getFormattedAmount(reportAction: ReportAction) { - if (!ReportActionsUtils.isSubmittedAction(reportAction) && !ReportActionsUtils.isForwardedAction(reportAction) && !ReportActionsUtils.isApprovedAction(reportAction) && !ReportActionsUtils.isSubmittedAndClosedAction(reportAction)) { + if ( + !ReportActionsUtils.isSubmittedAction(reportAction) && + !ReportActionsUtils.isForwardedAction(reportAction) && + !ReportActionsUtils.isApprovedAction(reportAction) && + !ReportActionsUtils.isSubmittedAndClosedAction(reportAction) + ) { return ''; } const originalMessage = ReportActionsUtils.getOriginalMessage(reportAction); @@ -4518,7 +4526,9 @@ function getFormattedAmount(reportAction: ReportAction) { return formattedAmount; } -function getReportAutomaticallySubmittedMessage(reportAction: ReportAction | ReportAction) { +function getReportAutomaticallySubmittedMessage( + reportAction: ReportAction | ReportAction, +) { return Localize.translateLocal('iou.automaticallySubmittedAmount', {formattedAmount: getFormattedAmount(reportAction)}); } diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 57ecb9f9c331..57dc8041b434 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) || ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED)) { + } 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 562e113b8e83..604bcb7d5eed 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) || ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.SUBMITTED_AND_CLOSED)) { + } 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 = (