11import { hasSeenTourSelector } from '@selectors/Onboarding' ;
2+ import { conciergePersonalDetailSelector , personalDetailByAccountIDSelector } from '@selectors/PersonalDetails' ;
23import mapValues from 'lodash/mapValues' ;
3- import React , { useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
4+ import React , { useEffect , useMemo , useRef , useState } from 'react' ;
45import { View } from 'react-native' ;
56import type { StyleProp , ViewStyle } from 'react-native' ;
67import type { OnyxEntry } from 'react-native-onyx' ;
@@ -70,7 +71,6 @@ import CONST from '@src/CONST';
7071import ONYXKEYS from '@src/ONYXKEYS' ;
7172import ROUTES from '@src/ROUTES' ;
7273import type * as OnyxTypes from '@src/types/onyx' ;
73- import type PersonalDetails from '@src/types/onyx/PersonalDetails' ;
7474import type { TransactionPendingFieldsKey } from '@src/types/onyx/Transaction' ;
7575import type { FileObject } from '@src/types/utils/Attachment' ;
7676import { isEmptyObject } from '@src/types/utils/EmptyObject' ;
@@ -112,13 +112,6 @@ const receiptImageViolationNames = new Set<OnyxTypes.ViolationName>([
112112
113113const receiptFieldViolationNames = new Set < OnyxTypes . ViolationName > ( [ CONST . VIOLATIONS . MODIFIED_AMOUNT , CONST . VIOLATIONS . MODIFIED_DATE ] ) ;
114114
115- const findConciergePersonalDetail = ( list : OnyxEntry < OnyxTypes . PersonalDetailsList > ) : OnyxEntry < PersonalDetails > => {
116- if ( ! list ) {
117- return undefined ;
118- }
119- return Object . values ( list ) . find ( ( detail ) : detail is PersonalDetails => detail ?. login === CONST . EMAIL . CONCIERGE ) ;
120- } ;
121-
122115function MoneyRequestReceiptView ( {
123116 report,
124117 readonly = false ,
@@ -141,16 +134,10 @@ function MoneyRequestReceiptView({
141134 const [ introSelected ] = useOnyx ( ONYXKEYS . NVP_INTRO_SELECTED ) ;
142135 const [ isSelfTourViewed ] = useOnyx ( ONYXKEYS . NVP_ONBOARDING , { selector : hasSeenTourSelector } ) ;
143136 const [ betas ] = useOnyx ( ONYXKEYS . BETAS ) ;
144- const [ conciergePersonalDetail ] = useOnyx ( ONYXKEYS . PERSONAL_DETAILS_LIST , { selector : findConciergePersonalDetail } ) ;
145- const reportOwnerSelector = useCallback (
146- ( list : OnyxEntry < OnyxTypes . PersonalDetailsList > ) : OnyxEntry < PersonalDetails > => ( report ?. ownerAccountID ? ( list ?. [ report . ownerAccountID ] ?? undefined ) : undefined ) ,
147- [ report ?. ownerAccountID ] ,
148- ) ;
137+ const [ conciergePersonalDetail ] = useOnyx ( ONYXKEYS . PERSONAL_DETAILS_LIST , { selector : conciergePersonalDetailSelector } ) ;
138+ const reportOwnerSelector = useMemo ( ( ) => personalDetailByAccountIDSelector ( report ?. ownerAccountID ) , [ report ?. ownerAccountID ] ) ;
149139 const [ reportOwnerPersonalDetail ] = useOnyx ( ONYXKEYS . PERSONAL_DETAILS_LIST , { selector : reportOwnerSelector } , [ reportOwnerSelector ] ) ;
150- const chatReportOwnerSelector = useCallback (
151- ( list : OnyxEntry < OnyxTypes . PersonalDetailsList > ) : OnyxEntry < PersonalDetails > => ( chatReport ?. ownerAccountID ? ( list ?. [ chatReport . ownerAccountID ] ?? undefined ) : undefined ) ,
152- [ chatReport ?. ownerAccountID ] ,
153- ) ;
140+ const chatReportOwnerSelector = useMemo ( ( ) => personalDetailByAccountIDSelector ( chatReport ?. ownerAccountID ) , [ chatReport ?. ownerAccountID ] ) ;
154141 const [ chatReportOwnerPersonalDetail ] = useOnyx ( ONYXKEYS . PERSONAL_DETAILS_LIST , { selector : chatReportOwnerSelector } , [ chatReportOwnerSelector ] ) ;
155142 const delegateAccountID = useDelegateAccountID ( ) ;
156143
0 commit comments