diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ce987540eb7af..98f0c88a64c08 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -11651,9 +11651,13 @@ function prepareOnboardingOnyxData({ let bespokeAction: OptimisticReportAction | undefined; if (shouldUseFollowupsInsteadOfTasks && companySize === CONST.ONBOARDING_COMPANY_SIZE.MICRO) { - bespokeWelcomeMessage = getBespokeWelcomeMessage(userReportedIntegration); + const bespokeMarkdown = getBespokeWelcomeMessage(userReportedIntegration); optimisticConciergeReportActionID = rand64(); - bespokeAction = buildOptimisticAddCommentReportAction(bespokeWelcomeMessage, undefined, CONST.ACCOUNT_ID.CONCIERGE, 2, targetChatReportID, optimisticConciergeReportActionID); + bespokeAction = buildOptimisticAddCommentReportAction(bespokeMarkdown, undefined, CONST.ACCOUNT_ID.CONCIERGE, 2, targetChatReportID, optimisticConciergeReportActionID); + // Reuse the HTML that buildOptimisticAddCommentReportAction already parsed via getParsedComment, + // so we avoid calling getParsedComment a second time with the same input. + // The backend passes this to the LLM as HTML for AddComment, which expects HTML. + bespokeWelcomeMessage = bespokeAction.commentText; } let createWorkspaceTaskReportID; diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index 9db06b91b9169..f495936f14f24 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -569,6 +569,9 @@ describe('ReportUtils', () => { const reportActionsEntries = result?.optimisticData.filter((i) => i.key === `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${adminsChatReportID}`); expect(reportActionsEntries).toHaveLength(1); expect(result?.bespokeWelcomeMessage).toBeDefined(); + // The bespoke message sent to the backend should be HTML (not raw markdown) + // so the server can pass it through to AddComment without formatting loss. + expect(result?.bespokeWelcomeMessage).toMatch(/<[^>]+>/); expect(result?.optimisticConciergeReportActionID).toBeDefined(); });