1- import React , { useMemo , useRef , useState } from 'react' ;
1+ import React , { useCallback , useMemo , useRef , useState } from 'react' ;
22// eslint-disable-next-line no-restricted-imports
33import type { GestureResponderEvent , ImageStyle , Text as RNText , TextStyle , ViewStyle } from 'react-native' ;
44import { Linking , View } from 'react-native' ;
@@ -93,10 +93,7 @@ function EmptySearchView({similarSearchHash, type, groupBy, hasResults}: EmptySe
9393 const { typeMenuSections} = useSearchTypeMenuSections ( ) ;
9494
9595 const [ allPolicies ] = useOnyx ( ONYXKEYS . COLLECTION . POLICY , { canBeMissing : false } ) ;
96- const [ isUserPaidPolicyMember = false ] = useOnyx ( ONYXKEYS . COLLECTION . POLICY , {
97- canBeMissing : true ,
98- selector : ( policies ) => Object . values ( policies ?? { } ) . some ( ( policy ) => isPaidGroupPolicy ( policy ) && isPolicyMember ( policy , currentUserPersonalDetails . login ) ) ,
99- } ) ;
96+
10097 const [ activePolicyID ] = useOnyx ( ONYXKEYS . NVP_ACTIVE_POLICY_ID , { canBeMissing : true } ) ;
10198 const [ activePolicy ] = useOnyx ( `${ ONYXKEYS . COLLECTION . POLICY } ${ activePolicyID } ` , { canBeMissing : true } ) ;
10299
@@ -108,6 +105,22 @@ function EmptySearchView({similarSearchHash, type, groupBy, hasResults}: EmptySe
108105 canBeMissing : true ,
109106 } ) ;
110107
108+ const isUserPaidPolicyMemberSelector = useCallback (
109+ ( policies : OnyxCollection < Policy > ) => {
110+ return Object . values ( policies ?? { } ) . some ( ( policy ) => isPaidGroupPolicy ( policy ) && isPolicyMember ( policy , currentUserPersonalDetails . login ) ) ;
111+ } ,
112+ [ currentUserPersonalDetails . login ] ,
113+ ) ;
114+
115+ const [ isUserPaidPolicyMember = false ] = useOnyx (
116+ ONYXKEYS . COLLECTION . POLICY ,
117+ {
118+ canBeMissing : true ,
119+ selector : isUserPaidPolicyMemberSelector ,
120+ } ,
121+ [ isUserPaidPolicyMemberSelector ] ,
122+ ) ;
123+
111124 return (
112125 < SearchScopeProvider >
113126 < EmptySearchViewContent
0 commit comments