diff --git a/src/CONST/index.ts b/src/CONST/index.ts index a71756cb7783..9b1040e31af8 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -777,7 +777,6 @@ const CONST = { ODOMETER_EXPENSES: 'odometerExpenses', NEW_DOT_HOME: 'newDotHome', SINGLE_USE_AND_EXPIRE_BY_CARDS: 'singleUseAndExpireByCards', - PAY_INVOICE_VIA_EXPENSIFY: 'payInvoiceViaExpensify', PERSONAL_CARD_IMPORT: 'personalCardImport', SUGGESTED_FOLLOWUPS: 'suggestedFollowups', }, diff --git a/src/components/SettlementButton/index.tsx b/src/components/SettlementButton/index.tsx index 308c2fe0541a..0f07f362d622 100644 --- a/src/components/SettlementButton/index.tsx +++ b/src/components/SettlementButton/index.tsx @@ -155,7 +155,6 @@ function SettlementButton({ const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: true}); const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); - const isPayInvoiceViaExpensifyBetaEnabled = isBetaEnabled(CONST.BETAS.PAY_INVOICE_VIA_EXPENSIFY); const hasViolations = hasViolationsReportUtils(iouReport?.reportID, transactionViolations, accountID, email ?? ''); const isInvoiceReport = (!isEmptyObject(iouReport) && isInvoiceReportUtil(iouReport)) || false; @@ -340,7 +339,7 @@ function SettlementButton({ } if (isInvoiceReport) { - const showPayViaExpensifyOptions = isPayInvoiceViaExpensifyBetaEnabled && isCurrencySupportedForGlobalReimbursement(currency as CurrencyType); + const isCurrencySupported = isCurrencySupportedForGlobalReimbursement(currency as CurrencyType); const hasActivePolicyAsAdmin = !!activePolicy && isPolicyAdmin(activePolicy) && isPaidGroupPolicy(activePolicy); const isActivePolicyCurrencySupported = isCurrencySupportedForDirectReimbursement(activePolicy?.outputCurrency ?? ''); @@ -382,8 +381,8 @@ function SettlementButton({ value: CONST.IOU.PAYMENT_TYPE.ELSEWHERE, }; return [ - ...(showPayViaExpensifyOptions ? getPaymentSubItems(payAsBusiness) : []), - ...(showPayViaExpensifyOptions && isPolicyCurrencySupported ? [addBankAccountItem] : []), + ...(isCurrencySupported ? getPaymentSubItems(payAsBusiness) : []), + ...(isCurrencySupported && isPolicyCurrencySupported ? [addBankAccountItem] : []), { text: translate('iou.payElsewhere', ''), icon: icons.Cash, @@ -400,24 +399,17 @@ function SettlementButton({ }; if (isIndividualInvoiceRoomUtil(chatReport)) { - // Gate default so main split button never triggers Pay via Expensify when beta is off (or currency unsupported). - let invoiceDefaultValue = lastPaymentMethod ?? CONST.IOU.PAYMENT_TYPE.ELSEWHERE; - if (showPayViaExpensifyOptions && (hasIntentToPay || lastPaymentMethod === CONST.IOU.PAYMENT_TYPE.EXPENSIFY)) { - invoiceDefaultValue = CONST.IOU.PAYMENT_TYPE.EXPENSIFY; - } else if (lastPaymentMethod === CONST.IOU.PAYMENT_TYPE.EXPENSIFY) { - invoiceDefaultValue = CONST.IOU.PAYMENT_TYPE.ELSEWHERE; - } buttonOptions.push({ text: translate('iou.settlePersonal', formattedAmount), icon: icons.User, - value: invoiceDefaultValue, + value: hasIntentToPay ? CONST.IOU.PAYMENT_TYPE.EXPENSIFY : (lastPaymentMethod ?? CONST.IOU.PAYMENT_TYPE.ELSEWHERE), backButtonText: translate('iou.individual'), subMenuItems: getInvoicesOptions(false), }); buttonOptions.push({ text: translate('iou.settleBusiness', formattedAmount), icon: icons.Building, - value: invoiceDefaultValue, + value: hasIntentToPay ? CONST.IOU.PAYMENT_TYPE.EXPENSIFY : (lastPaymentMethod ?? CONST.IOU.PAYMENT_TYPE.ELSEWHERE), backButtonText: translate('iou.business'), subMenuItems: getInvoicesOptions(true), }); @@ -455,7 +447,6 @@ function SettlementButton({ activeAdminPolicies, checkForNecessaryAction, icons, - isPayInvoiceViaExpensifyBetaEnabled, ]); const selectPaymentType = (event: KYCFlowEvent, iouPaymentType: PaymentMethodType) => { @@ -470,7 +461,7 @@ function SettlementButton({ if (isInvoiceReport) { // if user has intent to pay, we should get the only bank account information to pay the invoice. - if (hasIntentToPay && isPayInvoiceViaExpensifyBetaEnabled) { + if (hasIntentToPay) { const currentBankInformation = formattedPaymentMethods.at(0) as BankAccount; onPress( CONST.IOU.PAYMENT_TYPE.EXPENSIFY, diff --git a/src/hooks/useBulkPayOptions.ts b/src/hooks/useBulkPayOptions.ts index 7fba44dfa664..dc5f6aa4a679 100644 --- a/src/hooks/useBulkPayOptions.ts +++ b/src/hooks/useBulkPayOptions.ts @@ -24,7 +24,6 @@ import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails'; import {useMemoizedLazyExpensifyIcons} from './useLazyAsset'; import useLocalize from './useLocalize'; import useOnyx from './useOnyx'; -import usePermissions from './usePermissions'; import usePolicy from './usePolicy'; import useThemeStyles from './useThemeStyles'; @@ -68,8 +67,6 @@ function useBulkPayOptions({ const policy = usePolicy(selectedPolicyID); const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${selectedReportID}`, {canBeMissing: true}); const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${iouReport?.chatReportID}`, {canBeMissing: true}); - const {isBetaEnabled} = usePermissions(); - const isPayInvoiceViaExpensifyBetaEnabled = isBetaEnabled(CONST.BETAS.PAY_INVOICE_VIA_EXPENSIFY); const activeAdminPolicies = useActiveAdminPolicies(); const isIOUReport = isIOUReportUtil(selectedReportID); const isExpenseReport = isExpenseReportUtil(selectedReportID); @@ -177,7 +174,7 @@ function useBulkPayOptions({ } if (isInvoiceReport) { - const showPayViaExpensifyOptions = isPayInvoiceViaExpensifyBetaEnabled && isCurrencySupportedForGlobalReimbursement(currency as CurrencyType); + const isCurrencySupported = isCurrencySupportedForGlobalReimbursement(currency as CurrencyType); const getInvoicesOptions = (payAsBusiness: boolean) => { const addBankAccountItem = { text: translate('bankAccount.addBankAccount'), @@ -188,8 +185,8 @@ function useBulkPayOptions({ }, }; return [ - ...(showPayViaExpensifyOptions ? getPaymentSubItems(payAsBusiness) : []), - ...(showPayViaExpensifyOptions ? [addBankAccountItem] : []), + ...(isCurrencySupported ? getPaymentSubItems(payAsBusiness) : []), + ...(isCurrencySupported ? [addBankAccountItem] : []), { text: translate('iou.payElsewhere', ''), icon: icons.Cash, diff --git a/src/hooks/usePaymentOptions.ts b/src/hooks/usePaymentOptions.ts index 705637a2ecd4..4817355df715 100644 --- a/src/hooks/usePaymentOptions.ts +++ b/src/hooks/usePaymentOptions.ts @@ -24,7 +24,6 @@ import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails'; import {useMemoizedLazyExpensifyIcons} from './useLazyAsset'; import useLocalize from './useLocalize'; import useOnyx from './useOnyx'; -import usePermissions from './usePermissions'; import usePolicy from './usePolicy'; import useThemeStyles from './useThemeStyles'; @@ -101,8 +100,6 @@ function usePaymentOptions({ const isLoadingLastPaymentMethod = isLoadingOnyxValue(lastPaymentMethodResult); const [bankAccountList = getEmptyObject()] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST, {canBeMissing: true}); const [fundList = getEmptyObject()] = useOnyx(ONYXKEYS.FUND_LIST, {canBeMissing: true}); - const {isBetaEnabled} = usePermissions(); - const isPayInvoiceViaExpensifyBetaEnabled = isBetaEnabled(CONST.BETAS.PAY_INVOICE_VIA_EXPENSIFY); const lastPaymentMethodRef = useRef(lastPaymentMethod); useEffect(() => { @@ -166,7 +163,7 @@ function usePaymentOptions({ if (isInvoiceReport) { const formattedPaymentMethods = formatPaymentMethods(bankAccountList, fundList, styles, translate); - const showPayViaExpensifyOptions = isPayInvoiceViaExpensifyBetaEnabled && isCurrencySupportedForGlobalReimbursement(currency as CurrencyType); + const isCurrencySupported = isCurrencySupportedForGlobalReimbursement(currency as CurrencyType); const getPaymentSubItems = (payAsBusiness: boolean) => { const requiredAccountType = payAsBusiness ? CONST.BANK_ACCOUNT.TYPE.BUSINESS : CONST.BANK_ACCOUNT.TYPE.PERSONAL; return formattedPaymentMethods @@ -202,14 +199,14 @@ function usePaymentOptions({ value: CONST.IOU.PAYMENT_TYPE.ELSEWHERE, backButtonText: translate('iou.individual'), subMenuItems: [ - ...(showPayViaExpensifyOptions ? getPaymentSubItems(false) : []), + ...(isCurrencySupported ? getPaymentSubItems(false) : []), { text: translate('iou.payElsewhere', ''), icon: icons.Cash, value: CONST.IOU.PAYMENT_TYPE.ELSEWHERE, onSelected: () => onPress(CONST.IOU.PAYMENT_TYPE.ELSEWHERE), }, - ...(showPayViaExpensifyOptions ? [addBankAccountItem] : []), + ...(isCurrencySupported ? [addBankAccountItem] : []), ], }); } @@ -220,8 +217,8 @@ function usePaymentOptions({ value: CONST.IOU.PAYMENT_TYPE.ELSEWHERE, backButtonText: translate('iou.business'), subMenuItems: [ - ...(showPayViaExpensifyOptions ? getPaymentSubItems(true) : []), - ...(showPayViaExpensifyOptions ? [addBankAccountItem] : []), + ...(isCurrencySupported ? getPaymentSubItems(true) : []), + ...(isCurrencySupported ? [addBankAccountItem] : []), { text: translate('iou.payElsewhere', ''), icon: icons.Cash,