Skip to content

Commit b6df843

Browse files
committed
perf(ReportWelcomeText): avoid mapping all personal details
1 parent 215c0c8 commit b6df843

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

src/components/ReportWelcomeText.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {View} from 'react-native';
33
import type {OnyxEntry} from 'react-native-onyx';
44
import useEnvironment from '@hooks/useEnvironment';
55
import useLocalize from '@hooks/useLocalize';
6-
import useMappedPersonalDetails, {personalDetailMapper} from '@hooks/useMappedPersonalDetails';
76
import useOnyx from '@hooks/useOnyx';
87
import usePreferredPolicy from '@hooks/usePreferredPolicy';
98
import useReportAttributes from '@hooks/useReportAttributes';
@@ -28,7 +27,7 @@ import CONST from '@src/CONST';
2827
import type {IOUType} from '@src/CONST';
2928
import ONYXKEYS from '@src/ONYXKEYS';
3029
import ROUTES from '@src/ROUTES';
31-
import type {OnyxInputOrEntry, PersonalDetailsList, Policy, Report} from '@src/types/onyx';
30+
import type {Policy, Report} from '@src/types/onyx';
3231
import RenderHTML from './RenderHTML';
3332
import Text from './Text';
3433

@@ -45,7 +44,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) {
4544
const styles = useThemeStyles();
4645
const {environmentURL} = useEnvironment();
4746
const reportAttributes = useReportAttributes();
48-
const [personalDetails] = useMappedPersonalDetails(personalDetailMapper);
47+
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);
4948
const {isRestrictedToPreferredPolicy} = usePreferredPolicy();
5049
const isPolicyExpenseChat = isPolicyExpenseChatReportUtils(report);
5150
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
@@ -108,9 +107,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) {
108107
// If we are the only participant (e.g. solo group chat) then keep the current user personal details so the welcome message does not show up empty.
109108
const shouldExcludeCurrentUser = participantAccountIDs.length > 0;
110109
const participantAccountIDsExcludeCurrentUser = getParticipantsAccountIDsForDisplay(report, undefined, undefined, shouldExcludeCurrentUser);
111-
const participantPersonalDetailListExcludeCurrentUser = Object.values(
112-
getPersonalDetailsForAccountIDs(participantAccountIDsExcludeCurrentUser, personalDetails as OnyxInputOrEntry<PersonalDetailsList>),
113-
);
110+
const participantPersonalDetailListExcludeCurrentUser = Object.values(getPersonalDetailsForAccountIDs(participantAccountIDsExcludeCurrentUser, personalDetails));
114111
const welcomeMessage = SidebarUtils.getWelcomeMessage({
115112
report,
116113
policy,

0 commit comments

Comments
 (0)