Skip to content

Commit 33c4d40

Browse files
committed
fix: infinite loading header
1 parent fc63cbb commit 33c4d40

2 files changed

Lines changed: 66 additions & 1 deletion

File tree

src/libs/ReportUtils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5272,14 +5272,18 @@ function getReportNameInternal({
52725272
formattedName = getDisplayNameForParticipant({accountID: currentUserAccountID, shouldAddCurrentUserPostfix: true, personalDetailsData: personalDetails});
52735273
}
52745274

5275+
if (isConciergeChatReport(report)) {
5276+
formattedName = CONST.CONCIERGE_DISPLAY_NAME;
5277+
}
5278+
52755279
if (formattedName) {
52765280
return formatReportLastMessageText(isArchivedNonExpense ? generateArchivedReportName(formattedName) : formattedName);
52775281
}
52785282

52795283
// Not a room or PolicyExpenseChat, generate title from first 5 other participants
52805284
formattedName = buildReportNameFromParticipantNames({report, personalDetails});
52815285

5282-
return isArchivedNonExpense ? generateArchivedReportName(formattedName) : formattedName;
5286+
return isArchivedNonExpense ? generateArchivedReportName(formattedName) : formattedName || (report?.reportName ?? '');
52835287
}
52845288

52855289
/**

tests/unit/ReportUtilsTest.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,67 @@ describe('ReportUtils', () => {
744744
});
745745
});
746746

747+
describe('Fallback scenarios', () => {
748+
test('should fallback to report.reportName when primary name generation returns empty string', () => {
749+
const reportWithFallbackName: Report = {
750+
reportID: '3',
751+
reportName: 'Custom Report Name',
752+
ownerAccountID: undefined,
753+
participants: {},
754+
policyID: undefined,
755+
chatType: undefined,
756+
};
757+
758+
const result = getReportName(reportWithFallbackName);
759+
expect(result).toBe('Custom Report Name');
760+
});
761+
762+
test('should return empty string when both primary name generation and reportName are empty', () => {
763+
const reportWithoutName: Report = {
764+
reportID: '4',
765+
reportName: '',
766+
ownerAccountID: undefined,
767+
participants: {},
768+
policyID: undefined,
769+
chatType: undefined,
770+
};
771+
772+
const result = getReportName(reportWithoutName);
773+
expect(result).toBe('');
774+
});
775+
776+
test('should return empty string when reportName is undefined', () => {
777+
const reportWithUndefinedName: Report = {
778+
reportID: '5',
779+
reportName: undefined,
780+
ownerAccountID: undefined,
781+
participants: {},
782+
policyID: undefined,
783+
chatType: undefined,
784+
};
785+
786+
const result = getReportName(reportWithUndefinedName);
787+
expect(result).toBe('');
788+
});
789+
790+
test('should return Concierge display name for concierge chat report', async () => {
791+
const conciergeReportID = 'concierge-123';
792+
await Onyx.set(`${ONYXKEYS.CONCIERGE_REPORT_ID}`, conciergeReportID);
793+
794+
const conciergeReport: Report = {
795+
reportID: conciergeReportID,
796+
reportName: '',
797+
ownerAccountID: undefined,
798+
participants: {},
799+
policyID: undefined,
800+
chatType: undefined,
801+
};
802+
803+
const result = getReportName(conciergeReport);
804+
expect(result).toBe(CONST.CONCIERGE_DISPLAY_NAME);
805+
});
806+
});
807+
747808
describe('Automatically approved report message via automatic (not by a human) action is', () => {
748809
test('shown when the report is forwarded (Control feature)', () => {
749810
const expenseReport = {

0 commit comments

Comments
 (0)