Skip to content

Commit 0de214a

Browse files
authored
Merge pull request Expensify#66798 from thelullabyy/fix/63974/infinite-loading-header
Chat header's infinite loading after merge account
2 parents 8b04250 + 30616d4 commit 0de214a

2 files changed

Lines changed: 68 additions & 1 deletion

File tree

src/libs/ReportUtils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5297,14 +5297,20 @@ function getReportNameInternal({
52975297
formattedName = getDisplayNameForParticipant({accountID: currentUserAccountID, shouldAddCurrentUserPostfix: true, personalDetailsData: personalDetails});
52985298
}
52995299

5300+
if (isConciergeChatReport(report)) {
5301+
formattedName = CONST.CONCIERGE_DISPLAY_NAME;
5302+
}
5303+
53005304
if (formattedName) {
53015305
return formatReportLastMessageText(isArchivedNonExpense ? generateArchivedReportName(formattedName) : formattedName);
53025306
}
53035307

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

5307-
return isArchivedNonExpense ? generateArchivedReportName(formattedName) : formattedName;
5311+
const finalName = formattedName || (report?.reportName ?? '');
5312+
5313+
return isArchivedNonExpense ? generateArchivedReportName(finalName) : finalName;
53085314
}
53095315

53105316
/**

tests/unit/ReportUtilsTest.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,67 @@ describe('ReportUtils', () => {
823823
});
824824
});
825825

826+
describe('Fallback scenarios', () => {
827+
test('should fallback to report.reportName when primary name generation returns empty string', () => {
828+
const reportWithFallbackName: Report = {
829+
reportID: '3',
830+
reportName: 'Custom Report Name',
831+
ownerAccountID: undefined,
832+
participants: {},
833+
policyID: undefined,
834+
chatType: undefined,
835+
};
836+
837+
const result = getReportName(reportWithFallbackName);
838+
expect(result).toBe('Custom Report Name');
839+
});
840+
841+
test('should return empty string when both primary name generation and reportName are empty', () => {
842+
const reportWithoutName: Report = {
843+
reportID: '4',
844+
reportName: '',
845+
ownerAccountID: undefined,
846+
participants: {},
847+
policyID: undefined,
848+
chatType: undefined,
849+
};
850+
851+
const result = getReportName(reportWithoutName);
852+
expect(result).toBe('');
853+
});
854+
855+
test('should return empty string when reportName is undefined', () => {
856+
const reportWithUndefinedName: Report = {
857+
reportID: '5',
858+
reportName: undefined,
859+
ownerAccountID: undefined,
860+
participants: {},
861+
policyID: undefined,
862+
chatType: undefined,
863+
};
864+
865+
const result = getReportName(reportWithUndefinedName);
866+
expect(result).toBe('');
867+
});
868+
869+
test('should return Concierge display name for concierge chat report', async () => {
870+
const conciergeReportID = 'concierge-123';
871+
await Onyx.set(`${ONYXKEYS.CONCIERGE_REPORT_ID}`, conciergeReportID);
872+
873+
const conciergeReport: Report = {
874+
reportID: conciergeReportID,
875+
reportName: '',
876+
ownerAccountID: undefined,
877+
participants: {},
878+
policyID: undefined,
879+
chatType: undefined,
880+
};
881+
882+
const result = getReportName(conciergeReport);
883+
expect(result).toBe(CONST.CONCIERGE_DISPLAY_NAME);
884+
});
885+
});
886+
826887
describe('Automatically approved report message via automatic (not by a human) action is', () => {
827888
test('shown when the report is forwarded (Control feature)', () => {
828889
const expenseReport = {

0 commit comments

Comments
 (0)