@@ -115,6 +115,7 @@ import {
115115 isRootGroupChat,
116116 isSelfDMOrSelfDMThread,
117117 isWorkspaceMemberLeavingWorkspaceRoom,
118+ parseReportActionHtmlToText,
118119 parseReportRouteParams,
119120 prepareOnboardingOnyxData,
120121 pushTransactionViolationsOnyxData,
@@ -2820,16 +2821,94 @@ describe('ReportUtils', () => {
28202821 });
28212822
28222823 it('should return the correct parent navigation subtitle for the archived invoice report', () => {
2823- const actual = getParentNavigationSubtitle(baseArchivedPolicyExpenseChat, true);
2824+ const actual = getParentNavigationSubtitle(baseArchivedPolicyExpenseChat, undefined, true);
28242825 const normalizedActual = {...actual, reportName: actual.reportName?.replaceAll('\u00A0', ' ')};
28252826 expect(normalizedActual).toEqual({reportName: 'A workspace & Ragnar Lothbrok (archived)'});
28262827 });
28272828
28282829 it('should return the correct parent navigation subtitle for the non archived invoice report', () => {
2829- const actual = getParentNavigationSubtitle(baseArchivedPolicyExpenseChat, false);
2830+ const actual = getParentNavigationSubtitle(baseArchivedPolicyExpenseChat, undefined, false);
28302831 const normalizedActual = {...actual, reportName: actual.reportName?.replaceAll('\u00A0', ' ')};
28312832 expect(normalizedActual).toEqual({reportName: 'A workspace & Ragnar Lothbrok'});
28322833 });
2834+
2835+ it('should return empty object when report has no parent and is not expense or IOU', () => {
2836+ const chatReport: Report = {
2837+ reportID: '100',
2838+ lastReadTime: '2024-02-01 04:56:47.233',
2839+ reportName: 'Chat Report',
2840+ type: CONST.REPORT.TYPE.CHAT,
2841+ };
2842+ const actual = getParentNavigationSubtitle(chatReport, undefined);
2843+ expect(actual).toEqual({});
2844+ });
2845+
2846+ it('should pass conciergeReportID through to getReportName for parent report name resolution', () => {
2847+ const conciergeReportID = '999';
2848+ const conciergeParentReport: Report = {
2849+ reportID: conciergeReportID,
2850+ lastReadTime: '2024-02-01 04:56:47.233',
2851+ reportName: 'Concierge',
2852+ type: CONST.REPORT.TYPE.CHAT,
2853+ };
2854+ const childReport: Report = {
2855+ reportID: '1000',
2856+ lastReadTime: '2024-02-01 04:56:47.233',
2857+ parentReportID: conciergeReportID,
2858+ parentReportActionID: '1',
2859+ reportName: 'Child Thread',
2860+ type: CONST.REPORT.TYPE.CHAT,
2861+ };
2862+
2863+ const reportCollectionDataSet = toCollectionDataSet(ONYXKEYS.COLLECTION.REPORT, [conciergeParentReport, childReport], (report) => report.reportID);
2864+ return Onyx.multiSet({
2865+ ...reportCollectionDataSet,
2866+ })
2867+ .then(waitForBatchedUpdates)
2868+ .then(() => {
2869+ const actual = getParentNavigationSubtitle(childReport, conciergeReportID);
2870+ expect(actual.reportName).toBe('Concierge');
2871+ });
2872+ });
2873+
2874+ it('should return reportName and workspaceName when parent report exists and conciergeReportID is undefined', () => {
2875+ const actual = getParentNavigationSubtitle(baseArchivedPolicyExpenseChat, undefined, false);
2876+ expect(actual).toHaveProperty('reportName');
2877+ });
2878+ });
2879+
2880+ describe('parseReportActionHtmlToText', () => {
2881+ it('should return empty string for undefined reportAction', () => {
2882+ const result = parseReportActionHtmlToText(undefined, '123', undefined);
2883+ expect(result).toBe('');
2884+ });
2885+
2886+ it('should return text from reportAction message when no html', () => {
2887+ const reportAction = {
2888+ ...createRandomReportAction(1),
2889+ message: [{type: 'COMMENT', text: 'Hello world'}],
2890+ } as unknown as ReportAction;
2891+ const result = parseReportActionHtmlToText(reportAction, '123', undefined);
2892+ expect(result).toBe('Hello world');
2893+ });
2894+
2895+ it('should parse html to text with conciergeReportID', () => {
2896+ const reportAction = {
2897+ ...createRandomReportAction(1),
2898+ message: [{type: 'COMMENT', html: '<p>Hello world</p>', text: 'Hello world'}],
2899+ } as unknown as ReportAction;
2900+ const result = parseReportActionHtmlToText(reportAction, '123', '999');
2901+ expect(result).toBe('Hello world');
2902+ });
2903+
2904+ it('should handle conciergeReportID being undefined', () => {
2905+ const reportAction = {
2906+ ...createRandomReportAction(1),
2907+ message: [{type: 'COMMENT', html: '<p>Test message</p>', text: 'Test message'}],
2908+ } as unknown as ReportAction;
2909+ const result = parseReportActionHtmlToText(reportAction, '456', undefined);
2910+ expect(result).toBe('Test message');
2911+ });
28332912 });
28342913
28352914 describe('requiresAttentionFromCurrentUser', () => {
0 commit comments