@@ -74,6 +74,7 @@ import {
7474 getAvailableReportFields,
7575 getBillableAndTaxTotal,
7676 getChatByParticipants,
77+ getChatListItemReportName,
7778 getChatRoomSubtitle,
7879 getDefaultWorkspaceAvatar,
7980 getDisplayNameForParticipant,
@@ -15078,6 +15079,65 @@ describe('ReportUtils', () => {
1507815079 });
1507915080 });
1508015081
15082+ describe('getChatListItemReportName', () => {
15083+ const conciergeReportID = 'concierge-report-123';
15084+
15085+ beforeEach(async () => {
15086+ await Onyx.clear();
15087+ await waitForBatchedUpdates();
15088+ });
15089+
15090+ it('should return CONCIERGE_DISPLAY_NAME when conciergeReportID matches report ID', async () => {
15091+ const conciergeReport: Report = {
15092+ reportID: conciergeReportID,
15093+ type: CONST.REPORT.TYPE.CHAT,
15094+ };
15095+ await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${conciergeReportID}`, conciergeReport);
15096+ await waitForBatchedUpdates();
15097+
15098+ const action = {...createRandomReportAction(1)};
15099+ const result = getChatListItemReportName(action, conciergeReport, conciergeReportID);
15100+ expect(result).toBe(CONST.CONCIERGE_DISPLAY_NAME);
15101+ });
15102+
15103+ it('should not return CONCIERGE_DISPLAY_NAME when conciergeReportID does not match report ID', async () => {
15104+ const regularReport: Report = {
15105+ reportID: 'regular-report-456',
15106+ type: CONST.REPORT.TYPE.CHAT,
15107+ reportName: 'Regular Chat',
15108+ };
15109+ await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${regularReport.reportID}`, regularReport);
15110+ await waitForBatchedUpdates();
15111+
15112+ const action = {...createRandomReportAction(2)};
15113+ const result = getChatListItemReportName(action, regularReport, conciergeReportID);
15114+ expect(result).not.toBe(CONST.CONCIERGE_DISPLAY_NAME);
15115+ });
15116+
15117+ it('should return action.reportName when set, regardless of conciergeReportID', () => {
15118+ const conciergeReport: Report = {
15119+ reportID: conciergeReportID,
15120+ type: CONST.REPORT.TYPE.CHAT,
15121+ };
15122+ const action = {...createRandomReportAction(3), reportName: 'Custom Action Name'};
15123+ const result = getChatListItemReportName(action, conciergeReport, conciergeReportID);
15124+ expect(result).toBe('Custom Action Name');
15125+ });
15126+
15127+ it('should use Onyx-connected conciergeReportID when explicit parameter is undefined', async () => {
15128+ const conciergeReport: Report = {
15129+ reportID: conciergeReportID,
15130+ type: CONST.REPORT.TYPE.CHAT,
15131+ };
15132+ await Onyx.set(ONYXKEYS.CONCIERGE_REPORT_ID, conciergeReportID);
15133+ await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${conciergeReportID}`, conciergeReport);
15134+ await waitForBatchedUpdates();
15135+
15136+ const action = {...createRandomReportAction(4)};
15137+ const result = getChatListItemReportName(action, conciergeReport, undefined);
15138+ expect(result).toBe(CONST.CONCIERGE_DISPLAY_NAME);
15139+ });
15140+ });
1508115141 describe('buildOptimisticApprovedReportAction', () => {
1508215142 it('should set actorAccountID to the provided currentUserAccountID', () => {
1508315143 const customAccountID = 99;
0 commit comments