11import React , { useCallback , useMemo } from 'react' ;
22import type { StyleProp , ViewStyle } from 'react-native' ;
33import { View } from 'react-native' ;
4- import type { OnyxCollection , OnyxEntry } from 'react-native-onyx' ;
4+ import type { OnyxEntry } from 'react-native-onyx' ;
55import Avatar from '@components/Avatar' ;
66import { FallbackAvatar } from '@components/Icon/Expensicons' ;
77import MultipleAvatars from '@components/MultipleAvatars' ;
@@ -39,7 +39,7 @@ import {
3939import CONST from '@src/CONST' ;
4040import ONYXKEYS from '@src/ONYXKEYS' ;
4141import ROUTES from '@src/ROUTES' ;
42- import type { Policy , Report , ReportAction } from '@src/types/onyx' ;
42+ import type { Report , ReportAction } from '@src/types/onyx' ;
4343import type { Icon } from '@src/types/onyx/OnyxCommon' ;
4444import type ChildrenProps from '@src/types/utils/ChildrenProps' ;
4545import ReportActionItemDate from './ReportActionItemDate' ;
@@ -72,9 +72,6 @@ type ReportActionItemSingleProps = Partial<ChildrenProps> & {
7272
7373 /** If the action is being actived */
7474 isActive ?: boolean ;
75-
76- /** Policies */
77- policies ?: OnyxCollection < Policy > ;
7875} ;
7976
8077const showUserDetails = ( accountID : number | undefined ) => {
@@ -99,7 +96,6 @@ function ReportActionItemSingle({
9996 iouReport,
10097 isHovered = false ,
10198 isActive = false ,
102- policies,
10399} : ReportActionItemSingleProps ) {
104100 const theme = useTheme ( ) ;
105101 const styles = useThemeStyles ( ) ;
@@ -111,10 +107,9 @@ function ReportActionItemSingle({
111107 const ownerAccountID = iouReport ?. ownerAccountID ?? action ?. childOwnerAccountID ;
112108 const isReportPreviewAction = action ?. actionName === CONST . REPORT . ACTIONS . TYPE . REPORT_PREVIEW ;
113109 const actorAccountID = getReportActionActorAccountID ( action , iouReport , report , delegatePersonalDetails ) ;
114- const invoiceReceiverPolicy =
115- report ?. invoiceReceiver && 'policyID' in report . invoiceReceiver
116- ? policies ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ report . invoiceReceiver . policyID } ` ]
117- : policies ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ CONST . DEFAULT_NUMBER_ID } ` ] ;
110+ const [ invoiceReceiverPolicy ] = useOnyx (
111+ `${ ONYXKEYS . COLLECTION . POLICY } ${ report ?. invoiceReceiver && 'policyID' in report . invoiceReceiver ? report . invoiceReceiver . policyID : CONST . DEFAULT_NUMBER_ID } ` ,
112+ ) ;
118113
119114 let displayName = getDisplayNameForParticipant ( { accountID : actorAccountID , personalDetailsData : personalDetails } ) ;
120115 const { avatar, login, pendingFields, status, fallbackIcon} = personalDetails ?. [ actorAccountID ?? CONST . DEFAULT_NUMBER_ID ] ?? { } ;
0 commit comments