From 35372e5e105b14e3aaf8471e8355b9c0d2a5ceef Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 7 Dec 2023 23:31:17 +0800 Subject: [PATCH 1/2] handle submitted action copy to clipboard --- src/libs/ReportActionsUtils.ts | 5 +++++ src/pages/home/report/ContextMenu/ContextMenuActions.js | 3 +++ 2 files changed, 8 insertions(+) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 6dc735ebd8b7..a017cdc0b0ae 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -92,6 +92,10 @@ function isModifiedExpenseAction(reportAction: OnyxEntry): boolean return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE; } +function isSubmittedExpenseAction(reportAction: OnyxEntry): boolean { + return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.SUBMITTED; +} + function isWhisperAction(reportAction: OnyxEntry): boolean { return (reportAction?.whisperedToAccountIDs ?? []).length > 0; } @@ -693,6 +697,7 @@ export { isDeletedParentAction, isMessageDeleted, isModifiedExpenseAction, + isSubmittedExpenseAction, isMoneyRequestAction, isNotifiableReportAction, isPendingRemove, diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 4f35926c5957..e642f062d974 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -284,6 +284,9 @@ export default [ } else if (ReportActionsUtils.isChannelLogMemberAction(reportAction)) { const logMessage = ReportUtils.getChannelLogMemberMessage(reportAction); Clipboard.setString(logMessage); + } else if (ReportActionsUtils.isSubmittedExpenseAction(reportAction)) { + const submittedMessage = reportAction.message.reduce((acc, curr) => `${acc}${curr.text}`, ''); + Clipboard.setString(submittedMessage); } else if (content) { const parser = new ExpensiMark(); if (!Clipboard.canSetHtml()) { From b7d159eda292c26dc743421baab5f27d7b785298 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 7 Dec 2023 23:56:09 +0800 Subject: [PATCH 2/2] use underscore reduce --- src/pages/home/report/ContextMenu/ContextMenuActions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index e642f062d974..4f8fb98873d7 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -285,7 +285,7 @@ export default [ const logMessage = ReportUtils.getChannelLogMemberMessage(reportAction); Clipboard.setString(logMessage); } else if (ReportActionsUtils.isSubmittedExpenseAction(reportAction)) { - const submittedMessage = reportAction.message.reduce((acc, curr) => `${acc}${curr.text}`, ''); + const submittedMessage = _.reduce(reportAction.message, (acc, curr) => `${acc}${curr.text}`, ''); Clipboard.setString(submittedMessage); } else if (content) { const parser = new ExpensiMark();