diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index baa2a96d469a..4ebc21c1e91a 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -11798,15 +11798,19 @@ function prepareOnboardingOnyxData({ let bespokeAction: OptimisticReportAction | undefined; if (shouldUseFollowupsInsteadOfTasks) { - bespokeWelcomeMessage = getBespokeWelcomeMessage(companySize, userReportedIntegration); + const bespokeMarkdown = getBespokeWelcomeMessage(companySize, userReportedIntegration); optimisticConciergeReportActionID = rand64(); bespokeAction = buildOptimisticAddCommentReportAction({ - text: bespokeWelcomeMessage, + text: bespokeMarkdown, actorAccountID: CONST.ACCOUNT_ID.CONCIERGE, createdOffset: 2, reportID: targetChatReportID, reportActionID: 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 8677a34da792..20f39d96e624 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -632,7 +632,10 @@ describe('ReportUtils', () => { // suggestedFollowups beta adds a bespoke Concierge welcome action optimistically for all company sizes const reportActionsEntries = result?.optimisticData.filter((i) => i.key === `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${adminsChatReportID}`); expect(reportActionsEntries).toHaveLength(1); - expect(result?.bespokeWelcomeMessage).toContain('For a small team like yours'); + 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(); });