diff --git a/src/libs/ReportActionFollowupUtils/index.ts b/src/libs/ReportActionFollowupUtils/index.ts index cc6e9ab99199b..dd591ea2a79cf 100644 --- a/src/libs/ReportActionFollowupUtils/index.ts +++ b/src/libs/ReportActionFollowupUtils/index.ts @@ -1,3 +1,4 @@ +import render from 'dom-serializer'; import {DomUtils, parseDocument} from 'htmlparser2'; import {getReportActionMessage, isActionOfType} from '@libs/ReportActionsUtils'; import CONST from '@src/CONST'; @@ -53,7 +54,7 @@ function parseFollowupsFromHtml(html: string): Followup[] | null { const followupTextElement = DomUtils.getElementsByTagName('followup-text', followupEl, true).at(0); const followupResponseElement = DomUtils.getElementsByTagName('followup-response', followupEl, true).at(0); const text = followupTextElement ? DomUtils.textContent(followupTextElement) : ''; - const response = followupResponseElement ? DomUtils.textContent(followupResponseElement) : undefined; + const response = followupResponseElement ? render(followupResponseElement.children) : undefined; return {text, response}; }); } diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 6a63dc83c6e87..d8d1ae5455bc1 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -368,6 +368,7 @@ type BuildOptimisticAddCommentReportActionParams = { reportID?: string; reportActionID?: string; attachmentID?: string; + isHTML?: boolean; }; type OptimisticReportAction = { @@ -6399,8 +6400,9 @@ function buildOptimisticAddCommentReportAction({ reportID, reportActionID = rand64(), attachmentID, + isHTML = false, }: BuildOptimisticAddCommentReportActionParams): OptimisticReportAction { - const commentText = getParsedComment(text ?? '', {reportID}); + const commentText = isHTML ? (text ?? '') : getParsedComment(text ?? '', {reportID}); const attachmentHtml = getUploadingAttachmentHtml(file, attachmentID); const htmlForNewComment = `${commentText}${commentText && attachmentHtml ? '

' : ''}${attachmentHtml}`; diff --git a/src/libs/actions/Report/SuggestedFollowup.ts b/src/libs/actions/Report/SuggestedFollowup.ts index 5e55e0f7fa6ee..29b2e3cda2105 100644 --- a/src/libs/actions/Report/SuggestedFollowup.ts +++ b/src/libs/actions/Report/SuggestedFollowup.ts @@ -80,8 +80,10 @@ function resolveSuggestedFollowup( const optimisticConciergeAction = buildOptimisticAddCommentReportAction({ text: selectedFollowup.response, actorAccountID: CONST.ACCOUNT_ID.CONCIERGE, + createdOffset: 1, reportActionID: optimisticConciergeReportActionID, reportID, + isHTML: true, }); addOptimisticConciergeActionWithDelay(reportID, optimisticConciergeAction); diff --git a/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx b/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx index 69012e109252b..b4ee1c5468a79 100644 --- a/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx @@ -23,6 +23,7 @@ import Navigation from '@libs/Navigation/Navigation'; import Parser from '@libs/Parser'; import {getCleanedTagName, isPolicyAdmin} from '@libs/PolicyUtils'; import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager'; +import stripFollowupListFromHtml from '@libs/ReportActionFollowupUtils/stripFollowupListFromHtml'; import { getActionableCardFraudAlertMessage, getActionableMentionWhisperMessage, @@ -214,14 +215,15 @@ function getActionHtml(reportAction: OnyxInputOrEntry): string { /** Sets the HTML string to Clipboard */ function setClipboardMessage(content: string | undefined) { - if (!content) { + const strippedContent = stripFollowupListFromHtml(content); + if (!strippedContent) { return; } - const clipboardText = getClipboardText(content); + const clipboardText = getClipboardText(strippedContent); if (!Clipboard.canSetHtml()) { Clipboard.setString(clipboardText); } else { - Clipboard.setHtml(content, clipboardText); + Clipboard.setHtml(strippedContent, clipboardText); } }