Skip to content

Commit 8f3cc9a

Browse files
authored
Merge pull request Expensify#65748 from thelullabyy/fix/63974/infinite-loading-after-merge-acc
Chat header's infinite loading after merge account
2 parents c23f62e + 39124cf commit 8f3cc9a

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

src/libs/ReportUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5292,7 +5292,7 @@ function getReportNameInternal({
52925292
// Not a room or PolicyExpenseChat, generate title from first 5 other participants
52935293
formattedName = buildReportNameFromParticipantNames({report, personalDetails});
52945294

5295-
return isArchivedNonExpense ? generateArchivedReportName(formattedName) : formattedName;
5295+
return isArchivedNonExpense ? generateArchivedReportName(formattedName) : formattedName || (report?.reportName ?? '');
52965296
}
52975297

52985298
/**

tests/unit/ReportUtilsTest.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,50 @@ describe('ReportUtils', () => {
741741
expect(getReportName(expenseChatReport)).toEqual("Ragnar Lothbrok's expenses");
742742
});
743743
});
744+
745+
describe('Fallback scenarios', () => {
746+
test('should fallback to report.reportName when primary name generation returns empty string', () => {
747+
const reportWithFallbackName: Report = {
748+
reportID: '3',
749+
reportName: 'Custom Report Name',
750+
ownerAccountID: undefined,
751+
participants: {},
752+
policyID: undefined,
753+
chatType: undefined,
754+
};
755+
756+
const result = getReportName(reportWithFallbackName);
757+
expect(result).toBe('Custom Report Name');
758+
});
759+
760+
test('should return empty string when both primary name generation and reportName are empty', () => {
761+
const reportWithoutName: Report = {
762+
reportID: '4',
763+
reportName: '',
764+
ownerAccountID: undefined,
765+
participants: {},
766+
policyID: undefined,
767+
chatType: undefined,
768+
};
769+
770+
const result = getReportName(reportWithoutName);
771+
expect(result).toBe('');
772+
});
773+
774+
test('should return empty string when reportName is undefined', () => {
775+
const reportWithUndefinedName: Report = {
776+
reportID: '5',
777+
reportName: undefined,
778+
ownerAccountID: undefined,
779+
participants: {},
780+
policyID: undefined,
781+
chatType: undefined,
782+
};
783+
784+
const result = getReportName(reportWithUndefinedName);
785+
expect(result).toBe('');
786+
});
787+
});
744788
});
745789

746790
describe('requiresAttentionFromCurrentUser', () => {

0 commit comments

Comments
 (0)