From f4da52085b49a1e970aa7750beea09dc06f04935 Mon Sep 17 00:00:00 2001 From: thelullabyy Date: Wed, 9 Jul 2025 22:18:05 +0800 Subject: [PATCH 1/2] fix: infinite loading after merge acc --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 0beabb7b0db1f..776627d166f92 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5268,7 +5268,7 @@ function getReportNameInternal({ // Not a room or PolicyExpenseChat, generate title from first 5 other participants formattedName = buildReportNameFromParticipantNames({report, personalDetails}); - return isArchivedNonExpense ? generateArchivedReportName(formattedName) : formattedName; + return isArchivedNonExpense ? generateArchivedReportName(formattedName) : formattedName || (report?.reportName ?? ''); } /** From 39124cff33f373f8d684941f60665bf9c6c1dbe0 Mon Sep 17 00:00:00 2001 From: thelullabyy Date: Thu, 10 Jul 2025 13:54:25 +0800 Subject: [PATCH 2/2] chore: add tests --- tests/unit/ReportUtilsTest.ts | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index 760ea8005f972..715c7874b9e98 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -721,6 +721,50 @@ describe('ReportUtils', () => { expect(getReportName(expenseChatReport)).toEqual("Ragnar Lothbrok's expenses"); }); }); + + describe('Fallback scenarios', () => { + test('should fallback to report.reportName when primary name generation returns empty string', () => { + const reportWithFallbackName: Report = { + reportID: '3', + reportName: 'Custom Report Name', + ownerAccountID: undefined, + participants: {}, + policyID: undefined, + chatType: undefined, + }; + + const result = getReportName(reportWithFallbackName); + expect(result).toBe('Custom Report Name'); + }); + + test('should return empty string when both primary name generation and reportName are empty', () => { + const reportWithoutName: Report = { + reportID: '4', + reportName: '', + ownerAccountID: undefined, + participants: {}, + policyID: undefined, + chatType: undefined, + }; + + const result = getReportName(reportWithoutName); + expect(result).toBe(''); + }); + + test('should return empty string when reportName is undefined', () => { + const reportWithUndefinedName: Report = { + reportID: '5', + reportName: undefined, + ownerAccountID: undefined, + participants: {}, + policyID: undefined, + chatType: undefined, + }; + + const result = getReportName(reportWithUndefinedName); + expect(result).toBe(''); + }); + }); }); describe('requiresAttentionFromCurrentUser', () => {