Skip to content

Commit 5090861

Browse files
authored
Merge pull request #86713 from allgandalf/fix-fallback-avatar-use-default-avatar-url
Use deterministic default avatar instead of gray fallback when personal details unavailable
2 parents a9bb468 + 8ab12c1 commit 5090861

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/libs/ReportUtils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,7 +3247,7 @@ function getIconsForParticipants(participants: number[], personalDetails: OnyxIn
32473247
const avatars: Icon[] = [];
32483248

32493249
for (const accountID of participantsList) {
3250-
const avatarSource = personalDetails?.[accountID]?.avatar ?? FallbackAvatar;
3250+
const avatarSource = personalDetails?.[accountID]?.avatar ?? getDefaultAvatarURL({accountID});
32513251
const displayNameLogin = personalDetails?.[accountID]?.displayName ? personalDetails?.[accountID]?.displayName : personalDetails?.[accountID]?.login;
32523252
const userIcon = {
32533253
id: accountID,
@@ -3521,7 +3521,7 @@ function getParticipantIcon(accountID: number | undefined, personalDetails: Onyx
35213521

35223522
return {
35233523
id: accountID,
3524-
source: details?.avatar ?? FallbackAvatar,
3524+
source: details?.avatar ?? getDefaultAvatarURL({accountID}),
35253525
type: CONST.ICON_TYPE_AVATAR,
35263526
name: displayName,
35273527
fallbackIcon: details?.fallbackIcon,
@@ -3578,7 +3578,7 @@ function getIconsForExpenseRequest(report: OnyxInputOrEntry<Report>, personalDet
35783578
const workspaceIcon = getWorkspaceIcon(report, policy);
35793579
const actorDetails = parentReportAction?.actorAccountID ? personalDetails?.[parentReportAction.actorAccountID] : undefined;
35803580
const memberIcon = {
3581-
source: actorDetails?.avatar ?? FallbackAvatar,
3581+
source: actorDetails?.avatar ?? (parentReportAction?.actorAccountID ? getDefaultAvatarURL({accountID: parentReportAction.actorAccountID}) : FallbackAvatar),
35823582
id: parentReportAction?.actorAccountID,
35833583
type: CONST.ICON_TYPE_AVATAR,
35843584
name: actorDetails?.displayName ?? '',
@@ -3605,7 +3605,7 @@ function getIconsForChatThread(
36053605
const actorDisplayName = getDisplayNameOrDefault(actorDetails, '', false);
36063606
const actorIcon = {
36073607
id: actorAccountID,
3608-
source: actorDetails?.avatar ?? FallbackAvatar,
3608+
source: actorDetails?.avatar ?? (actorAccountID ? getDefaultAvatarURL({accountID: actorAccountID}) : FallbackAvatar),
36093609
name: formatPhoneNumber(actorDisplayName),
36103610
type: CONST.ICON_TYPE_AVATAR,
36113611
fallbackIcon: actorDetails?.fallbackIcon,
@@ -3699,15 +3699,15 @@ function getIconsForIOUReport(report: OnyxInputOrEntry<Report>, personalDetails:
36993699
const managerDetails = report?.managerID ? personalDetails?.[report.managerID] : undefined;
37003700
const ownerDetails = report?.ownerAccountID ? personalDetails?.[report.ownerAccountID] : undefined;
37013701
const managerIcon = {
3702-
source: managerDetails?.avatar ?? FallbackAvatar,
3702+
source: managerDetails?.avatar ?? (report?.managerID ? getDefaultAvatarURL({accountID: report.managerID}) : FallbackAvatar),
37033703
id: report?.managerID,
37043704
type: CONST.ICON_TYPE_AVATAR,
37053705
name: managerDetails?.displayName ?? '',
37063706
fallbackIcon: managerDetails?.fallbackIcon,
37073707
};
37083708
const ownerIcon = {
37093709
id: report?.ownerAccountID,
3710-
source: ownerDetails?.avatar ?? FallbackAvatar,
3710+
source: ownerDetails?.avatar ?? (report?.ownerAccountID ? getDefaultAvatarURL({accountID: report.ownerAccountID}) : FallbackAvatar),
37113711
type: CONST.ICON_TYPE_AVATAR,
37123712
name: ownerDetails?.displayName ?? '',
37133713
fallbackIcon: ownerDetails?.fallbackIcon,

tests/unit/ReportUtilsTest.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,12 +1076,12 @@ describe('ReportUtils', () => {
10761076
const participants = getIconsForParticipants([1, 2, 3, 4, 5], participantsPersonalDetails);
10771077
expect(participants).toHaveLength(5);
10781078

1079-
expect(participants.at(3)?.source).toBeInstanceOf(Function);
1079+
expect(typeof participants.at(3)?.source).toBe('string');
10801080
expect(participants.at(3)?.name).toBe('(833) 240-3627');
10811081
expect(participants.at(3)?.id).toBe(4);
10821082
expect(participants.at(3)?.type).toBe('avatar');
10831083

1084-
expect(participants.at(1)?.source).toBeInstanceOf(Function);
1084+
expect(typeof participants.at(1)?.source).toBe('string');
10851085
expect(participants.at(1)?.name).toBe('floki@vikings.net');
10861086
expect(participants.at(1)?.id).toBe(2);
10871087
expect(participants.at(1)?.type).toBe('avatar');
@@ -1126,12 +1126,12 @@ describe('ReportUtils', () => {
11261126
const sortedParticipants = sortIconsByName(participants, participantsPersonalDetails, localeCompare);
11271127
expect(sortedParticipants).toHaveLength(5);
11281128

1129-
expect(sortedParticipants.at(0)?.source).toBeInstanceOf(Function);
1129+
expect(typeof sortedParticipants.at(0)?.source).toBe('string');
11301130
expect(sortedParticipants.at(0)?.name).toBe('(833) 240-3627');
11311131
expect(sortedParticipants.at(0)?.id).toBe(4);
11321132
expect(sortedParticipants.at(0)?.type).toBe('avatar');
11331133

1134-
expect(sortedParticipants.at(1)?.source).toBeInstanceOf(Function);
1134+
expect(typeof sortedParticipants.at(1)?.source).toBe('string');
11351135
expect(sortedParticipants.at(1)?.name).toBe('floki@vikings.net');
11361136
expect(sortedParticipants.at(1)?.id).toBe(2);
11371137
expect(sortedParticipants.at(1)?.type).toBe('avatar');

0 commit comments

Comments
 (0)