Skip to content

Commit

Permalink
Merge pull request #24630 from hungvu193/fix-24569
Browse files Browse the repository at this point in the history
Fix: Copy to clipboard button does not copy content of an IOU edit comment
  • Loading branch information
pecanoro authored Aug 22, 2023
2 parents b26ed1c + 88a7c38 commit 600b089
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
15 changes: 15 additions & 0 deletions src/libs/ReportActionsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,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
);
}

/**
* @param {*} reportID
* @returns {[Object]}
Expand Down Expand Up @@ -627,5 +641,6 @@ export {
getReportAction,
getNumberOfMoneyRequests,
isSplitBillAction,
isTaskAction,
getAllReportActions,
};
13 changes: 6 additions & 7 deletions src/pages/home/report/ContextMenu/ContextMenuActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,18 @@ 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.REPORTPREVIEW &&
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),

// If return value is true, we switch the `text` and `icon` on
// `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) {
Expand All @@ -199,6 +195,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()) {
Expand Down

0 comments on commit 600b089

Please sign in to comment.