@@ -24,6 +24,7 @@ import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails';
2424import { useMemoizedLazyExpensifyIcons } from './useLazyAsset' ;
2525import useLocalize from './useLocalize' ;
2626import useOnyx from './useOnyx' ;
27+ import usePermissions from './usePermissions' ;
2728import usePolicy from './usePolicy' ;
2829import useThemeStyles from './useThemeStyles' ;
2930
@@ -100,6 +101,8 @@ function usePaymentOptions({
100101 const isLoadingLastPaymentMethod = isLoadingOnyxValue ( lastPaymentMethodResult ) ;
101102 const [ bankAccountList = getEmptyObject < BankAccountList > ( ) ] = useOnyx ( ONYXKEYS . BANK_ACCOUNT_LIST , { canBeMissing : true } ) ;
102103 const [ fundList = getEmptyObject < FundList > ( ) ] = useOnyx ( ONYXKEYS . FUND_LIST , { canBeMissing : true } ) ;
104+ const { isBetaEnabled} = usePermissions ( ) ;
105+ const isPayInvoiceViaExpensifyBetaEnabled = isBetaEnabled ( CONST . BETAS . PAY_INVOICE_VIA_EXPENSIFY ) ;
103106 const lastPaymentMethodRef = useRef ( lastPaymentMethod ) ;
104107
105108 useEffect ( ( ) => {
@@ -163,7 +166,7 @@ function usePaymentOptions({
163166
164167 if ( isInvoiceReport ) {
165168 const formattedPaymentMethods = formatPaymentMethods ( bankAccountList , fundList , styles , translate ) ;
166- const isCurrencySupported = isCurrencySupportedForGlobalReimbursement ( currency as CurrencyType ) ;
169+ const showPayViaExpensifyOptions = isPayInvoiceViaExpensifyBetaEnabled && isCurrencySupportedForGlobalReimbursement ( currency as CurrencyType ) ;
167170 const getPaymentSubItems = ( payAsBusiness : boolean ) => {
168171 const requiredAccountType = payAsBusiness ? CONST . BANK_ACCOUNT . TYPE . BUSINESS : CONST . BANK_ACCOUNT . TYPE . PERSONAL ;
169172 return formattedPaymentMethods
@@ -199,14 +202,14 @@ function usePaymentOptions({
199202 value : CONST . IOU . PAYMENT_TYPE . ELSEWHERE ,
200203 backButtonText : translate ( 'iou.individual' ) ,
201204 subMenuItems : [
202- ...( isCurrencySupported ? getPaymentSubItems ( false ) : [ ] ) ,
205+ ...( showPayViaExpensifyOptions ? getPaymentSubItems ( false ) : [ ] ) ,
203206 {
204207 text : translate ( 'iou.payElsewhere' , { formattedAmount : '' } ) ,
205208 icon : icons . Cash ,
206209 value : CONST . IOU . PAYMENT_TYPE . ELSEWHERE ,
207210 onSelected : ( ) => onPress ( CONST . IOU . PAYMENT_TYPE . ELSEWHERE ) ,
208211 } ,
209- ...( isCurrencySupported ? [ addBankAccountItem ] : [ ] ) ,
212+ ...( showPayViaExpensifyOptions ? [ addBankAccountItem ] : [ ] ) ,
210213 ] ,
211214 } ) ;
212215 }
@@ -217,8 +220,8 @@ function usePaymentOptions({
217220 value : CONST . IOU . PAYMENT_TYPE . ELSEWHERE ,
218221 backButtonText : translate ( 'iou.business' ) ,
219222 subMenuItems : [
220- ...( isCurrencySupported ? getPaymentSubItems ( true ) : [ ] ) ,
221- ...( isCurrencySupported ? [ addBankAccountItem ] : [ ] ) ,
223+ ...( showPayViaExpensifyOptions ? getPaymentSubItems ( true ) : [ ] ) ,
224+ ...( showPayViaExpensifyOptions ? [ addBankAccountItem ] : [ ] ) ,
222225 {
223226 text : translate ( 'iou.payElsewhere' , { formattedAmount : '' } ) ,
224227 icon : icons . Cash ,
0 commit comments