Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reimbursed message is not copied #34713

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -32,11 +32,16 @@ import type IconAsset from '@src/types/utils/IconAsset';
import {hideContextMenu, showContextMenu, 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 @@ -162,7 +167,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 @@ -220,7 +225,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 @@ -371,7 +376,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 @@ -392,11 +398,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
Loading