From fe13270f2c4eed4b1e4a1666272819943e5651df Mon Sep 17 00:00:00 2001 From: Hans Date: Wed, 16 Aug 2023 22:38:58 +0700 Subject: [PATCH 1/2] Fix: Copy to clipboard button does not copy content of an IOU edit comment --- src/pages/home/report/ContextMenu/ContextMenuActions.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 440cc46d6230..3e48b9190c35 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -175,11 +175,9 @@ export default [ successIcon: Expensicons.Checkmark, shouldShow: (type, reportAction) => type === CONTEXT_MENU_TYPES.REPORT_ACTION && - reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.IOU && reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED && reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED && reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.TASKREOPENED && - !ReportActionUtils.isCreatedTaskReportAction(reportAction) && !ReportUtils.isReportMessageAttachment(_.last(lodashGet(reportAction, ['message'], [{}]))) && !ReportActionUtils.isMessageDeleted(reportAction), @@ -198,6 +196,9 @@ export default [ const iouReport = ReportUtils.getReport(ReportActionUtils.getIOUReportIDFromReportActionPreview(reportAction)); const displayMessage = ReportUtils.getReportPreviewMessage(iouReport, reportAction); Clipboard.setString(displayMessage); + } else if (ReportActionUtils.isModifiedExpenseAction(reportAction)) { + const modifyExpenseMessage = ReportUtils.getModifiedExpenseMessage(reportAction); + Clipboard.setString(modifyExpenseMessage); } else if (content) { const parser = new ExpensiMark(); if (!Clipboard.canSetHtml()) { From 89c75f6e0fee4d056f51dfc30d1e77b3921542b0 Mon Sep 17 00:00:00 2001 From: Hans Date: Sat, 19 Aug 2023 01:37:22 +0700 Subject: [PATCH 2/2] update copy for taskAction --- src/libs/ReportActionsUtils.js | 15 +++++++++++++++ .../home/report/ContextMenu/ContextMenuActions.js | 7 +++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportActionsUtils.js b/src/libs/ReportActionsUtils.js index 74f55d9b91b6..b15120010100 100644 --- a/src/libs/ReportActionsUtils.js +++ b/src/libs/ReportActionsUtils.js @@ -588,6 +588,20 @@ function isSplitBillAction(reportAction) { return lodashGet(reportAction, 'originalMessage.type', '') === CONST.IOU.REPORT_ACTION_TYPE.SPLIT; } +/** + * + * @param {*} reportAction + * @returns {Boolean} + */ +function isTaskAction(reportAction) { + const reportActionName = lodashGet(reportAction, 'actionName', ''); + return ( + reportActionName === CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED || + reportActionName === CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED || + reportActionName === CONST.REPORT.ACTIONS.TYPE.TASKREOPENED + ); +} + export { getSortedReportActions, getLastVisibleAction, @@ -623,4 +637,5 @@ export { isPendingRemove, getReportAction, isSplitBillAction, + isTaskAction, }; diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 3e48b9190c35..9a5359e6767d 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -175,9 +175,6 @@ export default [ successIcon: Expensicons.Checkmark, shouldShow: (type, reportAction) => type === CONTEXT_MENU_TYPES.REPORT_ACTION && - reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED && - reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED && - reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.TASKREOPENED && !ReportUtils.isReportMessageAttachment(_.last(lodashGet(reportAction, ['message'], [{}]))) && !ReportActionUtils.isMessageDeleted(reportAction), @@ -185,9 +182,11 @@ export default [ // `ContextMenuItem` with `successText` and `successIcon` which will fallback to // the `text` and `icon` onPress: (closePopover, {reportAction, selection}) => { + const isTaskAction = ReportActionUtils.isTaskAction(reportAction); const isReportPreviewAction = ReportActionUtils.isReportPreviewAction(reportAction); const message = _.last(lodashGet(reportAction, 'message', [{}])); - const messageHtml = lodashGet(message, 'html', ''); + const originalMessage = _.get(reportAction, 'originalMessage', {}); + const messageHtml = isTaskAction ? lodashGet(originalMessage, 'html', '') : lodashGet(message, 'html', ''); const isAttachment = _.has(reportAction, 'isAttachment') ? reportAction.isAttachment : ReportUtils.isReportMessageAttachment(message); if (!isAttachment) {