diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 009724e73e93..0853bd9c18ce 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -24,14 +24,6 @@ function canUseSpotnanaTravel(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.SPOTNANA_TRAVEL) || canUseAllBetas(betas); } -function canUseCompanyCardFeeds(betas: OnyxEntry): boolean { - return !!betas?.includes(CONST.BETAS.COMPANY_CARD_FEEDS) || canUseAllBetas(betas); -} - -function canUseDirectFeeds(betas: OnyxEntry): boolean { - return !!betas?.includes(CONST.BETAS.DIRECT_FEEDS) || canUseAllBetas(betas); -} - function canUseNetSuiteUSATax(betas: OnyxEntry): boolean { return !!betas?.includes(CONST.BETAS.NETSUITE_USA_TAX) || canUseAllBetas(betas); } @@ -62,8 +54,6 @@ export default { canUseDupeDetection, canUseP2PDistanceRequests, canUseSpotnanaTravel, - canUseCompanyCardFeeds, - canUseDirectFeeds, canUseNetSuiteUSATax, canUseCombinedTrackSubmit, canUseCategoryAndTagApprovers, diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index 2c9c2975d1d2..11acbda1ebbe 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -12,7 +12,6 @@ import Section from '@components/Section'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; -import usePermissions from '@hooks/usePermissions'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import * as CardUtils from '@libs/CardUtils'; @@ -63,7 +62,6 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro const styles = useThemeStyles(); const {shouldUseNarrowLayout} = useResponsiveLayout(); const {translate} = useLocalize(); - const {canUseCompanyCardFeeds} = usePermissions(); const hasAccountingConnection = !isEmptyObject(policy?.connections); const isAccountingEnabled = !!policy?.areConnectionsEnabled || !isEmptyObject(policy?.connections); const isSyncTaxEnabled = @@ -120,31 +118,27 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro }, ]; - if (canUseCompanyCardFeeds) { - spendItems.push({ - icon: Illustrations.CompanyCard, - titleTranslationKey: 'workspace.moreFeatures.companyCards.title', - subtitleTranslationKey: 'workspace.moreFeatures.companyCards.subtitle', - isActive: policy?.areCompanyCardsEnabled ?? false, - pendingAction: policy?.pendingFields?.areCompanyCardsEnabled, - disabled: !isEmptyObject(CardUtils.removeExpensifyCardFromCompanyCards(cardFeeds?.settings?.companyCards)), - action: (isEnabled: boolean) => { - if (!policyID) { - return; - } - if (isEnabled && !isControlPolicy(policy)) { - Navigation.navigate( - ROUTES.WORKSPACE_UPGRADE.getRoute(policyID, CONST.UPGRADE_FEATURE_INTRO_MAPPING.companyCards.alias, ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID)), - ); - return; - } - Policy.enableCompanyCards(policyID, isEnabled); - }, - disabledAction: () => { - setIsDisableCompanyCardsWarningModalOpen(true); - }, - }); - } + spendItems.push({ + icon: Illustrations.CompanyCard, + titleTranslationKey: 'workspace.moreFeatures.companyCards.title', + subtitleTranslationKey: 'workspace.moreFeatures.companyCards.subtitle', + isActive: policy?.areCompanyCardsEnabled ?? false, + pendingAction: policy?.pendingFields?.areCompanyCardsEnabled, + disabled: !isEmptyObject(CardUtils.removeExpensifyCardFromCompanyCards(cardFeeds?.settings?.companyCards)), + action: (isEnabled: boolean) => { + if (!policyID) { + return; + } + if (isEnabled && !isControlPolicy(policy)) { + Navigation.navigate(ROUTES.WORKSPACE_UPGRADE.getRoute(policyID, CONST.UPGRADE_FEATURE_INTRO_MAPPING.companyCards.alias, ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID))); + return; + } + Policy.enableCompanyCards(policyID, isEnabled); + }, + disabledAction: () => { + setIsDisableCompanyCardsWarningModalOpen(true); + }, + }); const manageItems: Item[] = [ { diff --git a/src/pages/workspace/companyCards/addNew/AddNewCardPage.tsx b/src/pages/workspace/companyCards/addNew/AddNewCardPage.tsx index 1a3dce65788f..2fef7016df97 100644 --- a/src/pages/workspace/companyCards/addNew/AddNewCardPage.tsx +++ b/src/pages/workspace/companyCards/addNew/AddNewCardPage.tsx @@ -1,6 +1,5 @@ import React from 'react'; import {useOnyx} from 'react-native-onyx'; -import usePermissions from '@hooks/usePermissions'; import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading'; import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPolicyAndFullscreenLoading'; import CONST from '@src/CONST'; @@ -17,44 +16,27 @@ import SelectFeedType from './SelectFeedType'; function AddNewCardPage({policy}: WithPolicyAndFullscreenLoadingProps) { const policyID = policy?.id; const [addNewCardFeed] = useOnyx(ONYXKEYS.ADD_NEW_COMPANY_CARD); - const {canUseDirectFeeds} = usePermissions(); - const {currentStep} = addNewCardFeed ?? {}; - if (canUseDirectFeeds) { - switch (currentStep) { - case CONST.COMPANY_CARDS.STEP.SELECT_BANK: - return ; - case CONST.COMPANY_CARDS.STEP.SELECT_FEED_TYPE: - return ; - case CONST.COMPANY_CARDS.STEP.CARD_TYPE: - return ; - case CONST.COMPANY_CARDS.STEP.BANK_CONNECTION: - return ; - case CONST.COMPANY_CARDS.STEP.CARD_INSTRUCTIONS: - return ; - case CONST.COMPANY_CARDS.STEP.CARD_NAME: - return ; - case CONST.COMPANY_CARDS.STEP.CARD_DETAILS: - return ; - case CONST.COMPANY_CARDS.STEP.AMEX_CUSTOM_FEED: - return ; - default: - return ; - } - } else { - switch (currentStep) { - case CONST.COMPANY_CARDS.STEP.CARD_TYPE: - return ; - case CONST.COMPANY_CARDS.STEP.CARD_INSTRUCTIONS: - return ; - case CONST.COMPANY_CARDS.STEP.CARD_NAME: - return ; - case CONST.COMPANY_CARDS.STEP.CARD_DETAILS: - return ; - default: - return ; - } + switch (currentStep) { + case CONST.COMPANY_CARDS.STEP.SELECT_BANK: + return ; + case CONST.COMPANY_CARDS.STEP.SELECT_FEED_TYPE: + return ; + case CONST.COMPANY_CARDS.STEP.CARD_TYPE: + return ; + case CONST.COMPANY_CARDS.STEP.BANK_CONNECTION: + return ; + case CONST.COMPANY_CARDS.STEP.CARD_INSTRUCTIONS: + return ; + case CONST.COMPANY_CARDS.STEP.CARD_NAME: + return ; + case CONST.COMPANY_CARDS.STEP.CARD_DETAILS: + return ; + case CONST.COMPANY_CARDS.STEP.AMEX_CUSTOM_FEED: + return ; + default: + return ; } } diff --git a/src/pages/workspace/companyCards/addNew/CardInstructionsStep.tsx b/src/pages/workspace/companyCards/addNew/CardInstructionsStep.tsx index 1b49074a116a..969625b224d6 100644 --- a/src/pages/workspace/companyCards/addNew/CardInstructionsStep.tsx +++ b/src/pages/workspace/companyCards/addNew/CardInstructionsStep.tsx @@ -9,7 +9,6 @@ import ScrollView from '@components/ScrollView'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; -import usePermissions from '@hooks/usePermissions'; import useThemeStyles from '@hooks/useThemeStyles'; import * as CardUtils from '@libs/CardUtils'; import Parser from '@libs/Parser'; @@ -26,7 +25,6 @@ function CardInstructionsStep({policyID}: CardInstructionsStepProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const {isOffline} = useNetwork(); - const {canUseDirectFeeds} = usePermissions(); const [addNewCard] = useOnyx(ONYXKEYS.ADD_NEW_COMPANY_CARD); @@ -40,12 +38,12 @@ function CardInstructionsStep({policyID}: CardInstructionsStepProps) { const buttonTranslation = isStripeFeedProvider ? translate('common.submit') : translate('common.next'); const submit = () => { - if (canUseDirectFeeds && isStripeFeedProvider) { + if (isStripeFeedProvider) { Card.updateSelectedFeed(feedProvider, policyID ?? '-1'); Navigation.goBack(); return; } - if (!canUseDirectFeeds || isOtherBankSelected) { + if (isOtherBankSelected) { CompanyCards.setAddNewCompanyCardStepAndData({ step: CONST.COMPANY_CARDS.STEP.CARD_NAME, }); @@ -57,13 +55,13 @@ function CardInstructionsStep({policyID}: CardInstructionsStepProps) { }; const handleBackButtonPress = () => { - if (canUseDirectFeeds && isAmexFeedProvider) { + if (isAmexFeedProvider) { CompanyCards.setAddNewCompanyCardStepAndData({ step: CONST.COMPANY_CARDS.STEP.AMEX_CUSTOM_FEED, }); return; } - if (canUseDirectFeeds && isStripeFeedProvider) { + if (isStripeFeedProvider) { CompanyCards.setAddNewCompanyCardStepAndData({step: CONST.COMPANY_CARDS.STEP.SELECT_BANK}); return; } diff --git a/src/pages/workspace/companyCards/addNew/CardTypeStep.tsx b/src/pages/workspace/companyCards/addNew/CardTypeStep.tsx index 0957bfe1d694..7fded06b75f6 100644 --- a/src/pages/workspace/companyCards/addNew/CardTypeStep.tsx +++ b/src/pages/workspace/companyCards/addNew/CardTypeStep.tsx @@ -12,9 +12,7 @@ import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; -import usePermissions from '@hooks/usePermissions'; import useThemeStyles from '@hooks/useThemeStyles'; -import Navigation from '@navigation/Navigation'; import variables from '@styles/variables'; import * as CompanyCards from '@userActions/CompanyCards'; import CONST from '@src/CONST'; @@ -22,14 +20,13 @@ import ONYXKEYS from '@src/ONYXKEYS'; import type {CardFeedProvider} from '@src/types/onyx/CardFeeds'; type AvailableCompanyCardTypes = { - isAmexAvailable?: boolean; translate: LocaleContextProps['translate']; typeSelected?: CardFeedProvider; styles: StyleProp; }; -function getAvailableCompanyCardTypes({isAmexAvailable, translate, typeSelected, styles}: AvailableCompanyCardTypes) { - const defaultTypes = [ +function getAvailableCompanyCardTypes({translate, typeSelected, styles}: AvailableCompanyCardTypes) { + return [ { value: CONST.COMPANY_CARD.FEED_BANK_NAME.MASTER_CARD, text: translate('workspace.companyCards.addNewCard.cardProviders.cdf'), @@ -59,28 +56,6 @@ function getAvailableCompanyCardTypes({isAmexAvailable, translate, typeSelected, ), }, ]; - - if (!isAmexAvailable) { - return defaultTypes; - } - - return [ - { - value: CONST.COMPANY_CARD.FEED_BANK_NAME.AMEX, - text: translate('workspace.companyCards.addNewCard.cardProviders.gl1025'), - keyForList: CONST.COMPANY_CARD.FEED_BANK_NAME.AMEX, - isSelected: typeSelected === CONST.COMPANY_CARD.FEED_BANK_NAME.AMEX, - leftElement: ( - - ), - }, - ...defaultTypes, - ]; } function CardTypeStep() { @@ -88,9 +63,8 @@ function CardTypeStep() { const styles = useThemeStyles(); const [addNewCard] = useOnyx(ONYXKEYS.ADD_NEW_COMPANY_CARD); const [typeSelected, setTypeSelected] = useState(); - const {canUseDirectFeeds} = usePermissions(); const [isError, setIsError] = useState(false); - const data = getAvailableCompanyCardTypes({isAmexAvailable: !canUseDirectFeeds, translate, typeSelected, styles: styles.mr3}); + const data = getAvailableCompanyCardTypes({translate, typeSelected, styles: styles.mr3}); const {bankName, selectedBank, feedType} = addNewCard?.data ?? {}; const isOtherBankSelected = selectedBank === CONST.COMPANY_CARDS.BANKS.OTHER; const isNewCardTypeSelected = typeSelected !== feedType; @@ -103,7 +77,7 @@ function CardTypeStep() { step: CONST.COMPANY_CARDS.STEP.CARD_INSTRUCTIONS, data: { feedType: typeSelected, - bankName: isNewCardTypeSelected && (!canUseDirectFeeds || isOtherBankSelected) ? '' : bankName, + bankName: isNewCardTypeSelected && isOtherBankSelected ? '' : bankName, }, isEditing: false, }); @@ -115,11 +89,7 @@ function CardTypeStep() { }, [addNewCard?.data.feedType]); const handleBackButtonPress = () => { - if (canUseDirectFeeds) { - CompanyCards.setAddNewCompanyCardStepAndData({step: CONST.COMPANY_CARDS.STEP.SELECT_BANK}); - } else { - Navigation.goBack(); - } + CompanyCards.setAddNewCompanyCardStepAndData({step: CONST.COMPANY_CARDS.STEP.SELECT_BANK}); }; return ( diff --git a/src/pages/workspace/companyCards/addNew/DetailsStep.tsx b/src/pages/workspace/companyCards/addNew/DetailsStep.tsx index 1501124f15b7..a313275b6bb1 100644 --- a/src/pages/workspace/companyCards/addNew/DetailsStep.tsx +++ b/src/pages/workspace/companyCards/addNew/DetailsStep.tsx @@ -14,7 +14,6 @@ import TextInput from '@components/TextInput'; import TextLink from '@components/TextLink'; import useAutoFocusInput from '@hooks/useAutoFocusInput'; import useLocalize from '@hooks/useLocalize'; -import usePermissions from '@hooks/usePermissions'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import * as ValidationUtils from '@libs/ValidationUtils'; @@ -36,7 +35,6 @@ function DetailsStep({policyID}: DetailsStepProps) { const theme = useTheme(); const styles = useThemeStyles(); const {inputCallbackRef} = useAutoFocusInput(); - const {canUseDirectFeeds} = usePermissions(); const [addNewCard] = useOnyx(ONYXKEYS.ADD_NEW_COMPANY_CARD); const [lastSelectedFeed] = useOnyx(`${ONYXKEYS.COLLECTION.LAST_SELECTED_FEED}${policyID}`); const feedProvider = addNewCard?.data?.feedType; @@ -61,7 +59,7 @@ function DetailsStep({policyID}: DetailsStepProps) { }; const handleBackButtonPress = () => { - if (!canUseDirectFeeds || isOtherBankSelected) { + if (isOtherBankSelected) { CompanyCards.setAddNewCompanyCardStepAndData({step: CONST.COMPANY_CARDS.STEP.CARD_NAME}); return; }