Skip to content

Commit

Permalink
Merge pull request #34713 from bernhardoj/fix/34045-reimbursed-messag…
Browse files Browse the repository at this point in the history
…e-is-not-copied

Fix reimbursed message is not copied
  • Loading branch information
tylerkaraszewski authored Jan 26, 2024
2 parents 8a55c77 + 5f205e7 commit b4ccb0c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
5 changes: 0 additions & 5 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ function isModifiedExpenseAction(reportAction: OnyxEntry<ReportAction>): boolean
return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.MODIFIEDEXPENSE;
}

function isSubmittedExpenseAction(reportAction: OnyxEntry<ReportAction>): boolean {
return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.SUBMITTED;
}

function isWhisperAction(reportAction: OnyxEntry<ReportAction>): boolean {
return (reportAction?.whisperedToAccountIDs ?? []).length > 0;
}
Expand Down Expand Up @@ -834,7 +830,6 @@ export {
isDeletedParentAction,
isMessageDeleted,
isModifiedExpenseAction,
isSubmittedExpenseAction,
isMoneyRequestAction,
isNotifiableReportAction,
isPendingRemove,
Expand Down
19 changes: 12 additions & 7 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@ import type IconAsset from '@src/types/utils/IconAsset';
import {hideContextMenu, showDeleteModal} from './ReportActionContextMenu';

/** Gets the HTML version of the message in an action */
function getActionText(reportAction: OnyxEntry<ReportAction>): string {
function getActionHtml(reportAction: OnyxEntry<ReportAction>): string {
const message = reportAction?.message?.at(-1) ?? null;
return message?.html ?? '';
}

/** Gets the text version of the message in an action */
function getActionText(reportAction: OnyxEntry<ReportAction>): string {
return reportAction?.message?.reduce((acc, curr) => `${acc}${curr.text}`, '') ?? '';
}

/** Sets the HTML string to Clipboard */
function setClipboardMessage(content: string) {
const parser = new ExpensiMark();
Expand Down Expand Up @@ -160,7 +165,7 @@ const ContextMenuActions: ContextMenuAction[] = [
);
},
onPress: (closePopover, {reportAction}) => {
const html = getActionText(reportAction);
const html = getActionHtml(reportAction);
const {originalFileName, sourceURL} = getAttachmentDetails(html);
const sourceURLWithAuth = addEncryptedAuthTokenToURL(sourceURL ?? '');
const sourceID = (sourceURL?.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1];
Expand Down Expand Up @@ -218,7 +223,7 @@ const ContextMenuActions: ContextMenuAction[] = [
}
const editAction = () => {
if (!draftMessage) {
Report.saveReportActionDraft(reportID, reportAction, getActionText(reportAction));
Report.saveReportActionDraft(reportID, reportAction, getActionHtml(reportAction));
} else {
Report.deleteReportActionDraft(reportID, reportAction);
}
Expand Down Expand Up @@ -369,7 +374,8 @@ const ContextMenuActions: ContextMenuAction[] = [
onPress: (closePopover, {reportAction, selection}) => {
const isTaskAction = ReportActionsUtils.isTaskAction(reportAction);
const isReportPreviewAction = ReportActionsUtils.isReportPreviewAction(reportAction);
const messageHtml = isTaskAction ? TaskUtils.getTaskReportActionMessage(reportAction?.actionName) : getActionText(reportAction);
const messageHtml = isTaskAction ? TaskUtils.getTaskReportActionMessage(reportAction?.actionName) : getActionHtml(reportAction);
const messageText = getActionText(reportAction);

const isAttachment = ReportActionsUtils.isReportActionAttachment(reportAction);
if (!isAttachment) {
Expand All @@ -390,11 +396,10 @@ const ContextMenuActions: ContextMenuAction[] = [
} else if (ReportActionsUtils.isMemberChangeAction(reportAction)) {
const logMessage = ReportActionsUtils.getMemberChangeMessageFragment(reportAction).html ?? '';
setClipboardMessage(logMessage);
} else if (ReportActionsUtils.isSubmittedExpenseAction(reportAction)) {
const submittedMessage = reportAction?.message?.reduce((acc, curr) => `${acc}${curr.text}`, '');
Clipboard.setString(submittedMessage ?? '');
} else if (content) {
setClipboardMessage(content);
} else if (messageText) {
Clipboard.setString(messageText);
}
}

Expand Down

0 comments on commit b4ccb0c

Please sign in to comment.