Skip to content

Commit 3e5cdde

Browse files
committed
reuse personalDetailsSelector in DelegateOnBehalfOfText
1 parent 26a9884 commit 3e5cdde

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/pages/inbox/report/DelegateOnBehalfOfText.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
import {personalDetailsSelector} from '@selectors/PersonalDetails';
12
import React from 'react';
2-
import type {OnyxEntry} from 'react-native-onyx';
33
import Text from '@components/Text';
44
import useLocalize from '@hooks/useLocalize';
55
import useOnyx from '@hooks/useOnyx';
66
import useThemeStyles from '@hooks/useThemeStyles';
77
import {getPersonalDetailByEmail} from '@libs/PersonalDetailsUtils';
8+
import CONST from '@src/CONST';
89
import ONYXKEYS from '@src/ONYXKEYS';
9-
import type * as OnyxTypes from '@src/types/onyx';
1010

1111
type DelegateOnBehalfOfTextProps = {
1212
/** The account ID whose login drives the "on behalf of" name. */
@@ -19,9 +19,7 @@ type DelegateOnBehalfOfTextProps = {
1919
function DelegateOnBehalfOfText({mainAccountID, fallbackLogin}: DelegateOnBehalfOfTextProps) {
2020
const styles = useThemeStyles();
2121
const {translate} = useLocalize();
22-
const [resolvedDetail] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {
23-
selector: (list: OnyxEntry<OnyxTypes.PersonalDetailsList>) => (mainAccountID ? list?.[mainAccountID] : undefined),
24-
});
22+
const [resolvedDetail] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsSelector(mainAccountID ?? CONST.DEFAULT_NUMBER_ID)});
2523
const mainAccountLogin = resolvedDetail?.login ?? fallbackLogin;
2624
const accountOwnerDetails = getPersonalDetailByEmail(String(mainAccountLogin ?? ''));
2725
return <Text style={[styles.chatDelegateMessage]}>{translate('delegate.onBehalfOfMessage', accountOwnerDetails?.displayName ?? '')}</Text>;

0 commit comments

Comments
 (0)