diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 5d161b8a5e76..c9d064776cd5 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1944,9 +1944,11 @@ function getWorkspaceIcon(report: OnyxInputOrEntry, policy?: OnyxInputOr if (iconFromCache && (isSameAvatarURL || isDefaultWorkspaceAvatar) && !hasWorkSpaceNameChanged) { return iconFromCache.icon; } - // `avatarURL` can be an empty string, so we have to use || operator here + // disabling to protect against empty strings // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const policyExpenseChatAvatarSource = avatarURL || getDefaultWorkspaceAvatar(workspaceName); + const policyAvatarURL = report?.policyAvatar || allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`]?.avatarURL; + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + const policyExpenseChatAvatarSource = policyAvatarURL || getDefaultWorkspaceAvatar(workspaceName); const workspaceIcon: Icon = { source: policyExpenseChatAvatarSource ?? '', diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 709dbc1c0685..4222d9e7b809 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -209,6 +209,7 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro avatarUrl: reportOnyx?.avatarUrl, permissions, invoiceReceiver: reportOnyx?.invoiceReceiver, + policyAvatar: reportOnyx?.policyAvatar, }), [ reportOnyx?.lastReadTime, @@ -251,6 +252,7 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro reportOnyx?.avatarUrl, permissions, reportOnyx?.invoiceReceiver, + reportOnyx?.policyAvatar, ], ); diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index 14fd2bd3ac81..0a545cb8e4dc 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -116,6 +116,9 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< /** The current user's notification preference for this report */ notificationPreference?: NotificationPreference; + /** The policy avatar to use, if any */ + policyAvatar?: string | null; + /** The policy name to use */ policyName?: string | null;