@@ -9,6 +9,7 @@ import {Bank} from '@components/Icon/Expensicons';
99import KYCWall from '@components/KYCWall' ;
1010import type { PaymentMethod } from '@components/KYCWall/types' ;
1111import { LockedAccountContext } from '@components/LockedAccountModalProvider' ;
12+ import { useSearchContext } from '@components/Search/SearchContext' ;
1213import useLocalize from '@hooks/useLocalize' ;
1314import useNetwork from '@hooks/useNetwork' ;
1415import useOnyx from '@hooks/useOnyx' ;
@@ -88,6 +89,8 @@ function SettlementButton({
8889 const styles = useThemeStyles ( ) ;
8990 const { translate} = useLocalize ( ) ;
9091 const { isOffline} = useNetwork ( ) ;
92+ const { isOnSearch} = useSearchContext ( ) ;
93+
9194 // The app would crash due to subscribing to the entire report collection if chatReportID is an empty string. So we should have a fallback ID here.
9295 // eslint-disable-next-line rulesdir/no-default-id-values
9396 const [ chatReport ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ chatReportID || CONST . DEFAULT_NUMBER_ID } ` , { canBeMissing : true } ) ;
@@ -107,7 +110,7 @@ function SettlementButton({
107110 const [ fundList = { } ] = useOnyx ( ONYXKEYS . FUND_LIST , { canBeMissing : true } ) ;
108111 const [ policies ] = useOnyx ( ONYXKEYS . COLLECTION . POLICY , { canBeMissing : true } ) ;
109112 const currentUserAccountID = getCurrentUserAccountID ( ) . toString ( ) ;
110- const activeAdminPolicies = getActiveAdminWorkspaces ( policies , currentUserAccountID ) . sort ( ( a , b ) => ( a . name || '' ) . localeCompare ( b . name || '' ) ) ;
113+ const activeAdminPolicies = getActiveAdminWorkspaces ( ! isOnSearch ? policies : undefined , currentUserAccountID ) . sort ( ( a , b ) => ( a . name || '' ) . localeCompare ( b . name || '' ) ) ;
111114 const reportID = iouReport ?. reportID ;
112115
113116 const hasPreferredPaymentMethod = ! ! lastPaymentMethod ;
@@ -556,6 +559,7 @@ function SettlementButton({
556559 const shouldUseSplitButton = hasPreferredPaymentMethod || ! ! lastPaymentPolicy || ( ( isInvoiceReport || isExpenseReportUtil ( iouReport ) ) && hasIntentToPay ) ;
557560 const shouldLimitWidth = shouldUseShortForm && shouldUseSplitButton && ! paymentButtonOptions . length ;
558561
562+ console . log ( { activeAdminPolicies, policies} ) ;
559563 return (
560564 < KYCWall
561565 onSuccessfulKYC = { ( paymentType ) => onPress ( paymentType , undefined , undefined ) }
0 commit comments