diff --git a/src/libs/UserUtils.ts b/src/libs/UserUtils.ts index 55a6c81f0417..761d4788584c 100644 --- a/src/libs/UserUtils.ts +++ b/src/libs/UserUtils.ts @@ -1,13 +1,9 @@ import Str from 'expensify-common/lib/str'; -import _ from 'lodash'; import type {OnyxEntry} from 'react-native-onyx'; -import Onyx from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import * as defaultAvatars from '@components/Icon/DefaultAvatars'; import {ConciergeAvatar, FallbackAvatar} from '@components/Icon/Expensicons'; import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; -import type {PersonalDetailsList} from '@src/types/onyx'; import type Login from '@src/types/onyx/Login'; import type IconAsset from '@src/types/utils/IconAsset'; import hashCode from './hashCode'; @@ -18,12 +14,6 @@ type AvatarSource = IconAsset | string; type LoginListIndicator = ValueOf | ''; -let allPersonalDetails: OnyxEntry; -Onyx.connect({ - key: ONYXKEYS.PERSONAL_DETAILS_LIST, - callback: (val) => (allPersonalDetails = _.isEmpty(val) ? {} : val), -}); - /** * Searches through given loginList for any contact method / login with an error. * @@ -116,19 +106,15 @@ function getDefaultAvatar(accountID = -1, avatarURL?: string): IconAsset { } /** - * Helper method to return default avatar URL associated with login + * Helper method to return default avatar URL associated with the accountID */ function getDefaultAvatarURL(accountID: string | number = ''): string { if (Number(accountID) === CONST.ACCOUNT_ID.CONCIERGE) { return CONST.CONCIERGE_ICON_URL; } - // To ensure that the avatar remains unchanged and matches the one returned by the backend, - // utilize an optimistic ID generated from the email instead of directly using the user ID. - const email = allPersonalDetails?.[accountID]?.login; - const originalOptimisticAccountID = email ? generateAccountID(email) : accountID; // Note that Avatar count starts at 1 which is why 1 has to be added to the result (or else 0 would result in a broken avatar link) - const accountIDHashBucket = (Number(originalOptimisticAccountID) % CONST.DEFAULT_AVATAR_COUNT) + 1; + const accountIDHashBucket = (Number(accountID) % CONST.DEFAULT_AVATAR_COUNT) + 1; const avatarPrefix = `default-avatar`; return `${CONST.CLOUDFRONT_URL}/images/avatars/${avatarPrefix}_${accountIDHashBucket}.png`;