Skip to content

Commit 18a61e8

Browse files
committed
Fix Message sent by sender & receiver show the same invoice room avatar
1 parent 35efc11 commit 18a61e8

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/components/ReportActionAvatars/useReportActionAvatars.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,20 @@ function useReportActionAvatars({
167167
fallbackIcon,
168168
};
169169

170-
const avatarsForAccountIDs: IconType[] = accountIDs.map((id) => ({
170+
const shouldUseActorAccountID = isAInvoiceReport && !isAReportPreviewAction;
171+
const accountIDsToMap = shouldUseActorAccountID && actorAccountID ? [actorAccountID] : accountIDs;
172+
173+
const avatarsForAccountIDs: IconType[] = accountIDsToMap.map((id) => ({
171174
id,
172175
type: CONST.ICON_TYPE_AVATAR,
173176
source: personalDetails?.[id]?.avatar ?? FallbackAvatar,
174-
name: personalDetails?.[id]?.login ?? '',
177+
name: personalDetails?.[id]?.[shouldUseActorAccountID ? 'displayName' : 'login'] ?? '',
175178
}));
176179

180+
const shouldUseMappedAccountIDs = avatarsForAccountIDs.length > 0 && (avatarType === CONST.REPORT_ACTION_AVATARS.TYPE.MULTIPLE || shouldUseActorAccountID);
181+
177182
return {
178-
avatars: avatarsForAccountIDs.length > 0 && avatarType === CONST.REPORT_ACTION_AVATARS.TYPE.MULTIPLE ? avatarsForAccountIDs : [primaryAvatar, secondaryAvatar],
183+
avatars: shouldUseMappedAccountIDs ? avatarsForAccountIDs : [primaryAvatar, secondaryAvatar],
179184
avatarType,
180185
details: {
181186
...(personalDetails?.[accountID] ?? {}),

0 commit comments

Comments
 (0)