From 9be3a06779ff756ad53912e01a2a5fc981e5c1e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= Date: Mon, 16 Sep 2024 16:20:30 +0100 Subject: [PATCH 1/2] Bump Onyx to v2.0.68 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2271cc6d6692e..02078cd354e09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -95,7 +95,7 @@ "react-native-launch-arguments": "^4.0.2", "react-native-localize": "^2.2.6", "react-native-modal": "^13.0.0", - "react-native-onyx": "2.0.66", + "react-native-onyx": "2.0.68", "react-native-pager-view": "6.4.1", "react-native-pdf": "6.7.5", "react-native-performance": "^5.1.0", @@ -36646,9 +36646,9 @@ } }, "node_modules/react-native-onyx": { - "version": "2.0.66", - "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-2.0.66.tgz", - "integrity": "sha512-Ns9WzcAjarAUl9g/bftf2EUJYdgcb6BAraxwqBWVeGWk3dGBR1hVEvZ7p/3rpKjidJQqiM3LWBaM6DkNHoYd1g==", + "version": "2.0.68", + "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-2.0.68.tgz", + "integrity": "sha512-KzcG8r6oIHRZhtiGu2XtHwYLm6eTp74r4NyhIawinfJEgcd1YMC6KdrVMqd1J7zFLTuBXPhtjiugTbUhXraFag==", "dependencies": { "ascii-table": "0.0.9", "fast-equals": "^4.0.3", diff --git a/package.json b/package.json index bf7df2e8576a9..bee2887c942ec 100644 --- a/package.json +++ b/package.json @@ -152,7 +152,7 @@ "react-native-launch-arguments": "^4.0.2", "react-native-localize": "^2.2.6", "react-native-modal": "^13.0.0", - "react-native-onyx": "2.0.66", + "react-native-onyx": "2.0.68", "react-native-pager-view": "6.4.1", "react-native-pdf": "6.7.5", "react-native-performance": "^5.1.0", From b09f94ed8e5214585f98b9a2d34d3022ad887ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Henriques?= Date: Mon, 16 Sep 2024 16:24:07 +0100 Subject: [PATCH 2/2] Revert #49173 --- src/libs/CardUtils.ts | 20 ------------------- .../workspace/WorkspaceMoreFeaturesPage.tsx | 4 ++-- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/libs/CardUtils.ts b/src/libs/CardUtils.ts index 58dbc07aae8de..a317fccda5502 100644 --- a/src/libs/CardUtils.ts +++ b/src/libs/CardUtils.ts @@ -27,14 +27,6 @@ Onyx.connect({ }, }); -let allCardsLists: OnyxCollection; - -Onyx.connect({ - key: ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, - waitForCollectionCallback: true, - callback: (value) => (allCardsLists = value), -}); - /** * @returns string with a month in MM format */ @@ -203,17 +195,6 @@ function getCardFeedIcon(cardFeed: string): IconAsset { return Illustrations.AmexCompanyCards; } -/** Checks if the Expensify Card toggle should be disabled */ -function shouldExpensifyCardToggleBeDisabled(workspaceAccountID?: number, areExpensifyCardsEnabled?: boolean): boolean { - if (!areExpensifyCardsEnabled || !workspaceAccountID) { - return false; - } - - const cardsList = allCardsLists?.[`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`]; - - return !isEmptyObject(cardsList); -} - function getCardDetailsImage(cardFeed: string): IconAsset { if (cardFeed.startsWith(CONST.COMPANY_CARD.FEED_BANK_NAME.MASTER_CARD)) { return Illustrations.MasterCardCompanyCardDetail; @@ -262,7 +243,6 @@ export { getEligibleBankAccountsForCard, sortCardsByCardholderName, getCardFeedIcon, - shouldExpensifyCardToggleBeDisabled, getCardDetailsImage, getMemberCards, }; diff --git a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx index bd6f9ce158f32..0182f1ea8827b 100644 --- a/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx +++ b/src/pages/workspace/WorkspaceMoreFeaturesPage.tsx @@ -15,7 +15,6 @@ 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'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {FullScreenNavigatorParamList} from '@libs/Navigation/types'; @@ -72,6 +71,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro !!policy?.connections?.netsuite?.options?.config?.syncOptions?.syncTax; const policyID = policy?.id; const workspaceAccountID = policy?.workspaceAccountID ?? -1; + const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID.toString()}_${CONST.EXPENSIFY_CARD.BANK}`); const [cardFeeds] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID.toString()}`); const [isOrganizeWarningModalOpen, setIsOrganizeWarningModalOpen] = useState(false); const [isIntegrateWarningModalOpen, setIsIntegrateWarningModalOpen] = useState(false); @@ -110,7 +110,7 @@ function WorkspaceMoreFeaturesPage({policy, route}: WorkspaceMoreFeaturesPagePro subtitleTranslationKey: 'workspace.moreFeatures.expensifyCard.subtitle', isActive: policy?.areExpensifyCardsEnabled ?? false, pendingAction: policy?.pendingFields?.areExpensifyCardsEnabled, - disabled: CardUtils.shouldExpensifyCardToggleBeDisabled(policy?.workspaceAccountID, policy?.areExpensifyCardsEnabled), + disabled: !isEmptyObject(cardsList), action: (isEnabled: boolean) => { if (!policyID) { return;