From 8ab00bb385547762c8a352cc223ddc638ff89ea4 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Wed, 18 Sep 2024 20:43:27 +0200 Subject: [PATCH 01/17] update addBillingCardAndRequestPolicyOwnerChange to handle GBP --- src/libs/actions/Policy/Policy.ts | 58 ++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index e30ddaf97e1f..8ff06ae77930 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -9,6 +9,7 @@ import type {ReportExportType} from '@components/ButtonWithDropdownMenu/types'; import * as API from '@libs/API'; import type { AddBillingCardAndRequestWorkspaceOwnerChangeParams, + AddPaymentCardParams, CreateWorkspaceFromIOUPaymentParams, CreateWorkspaceParams, DeleteWorkspaceAvatarParams, @@ -59,7 +60,7 @@ import type { UpdateWorkspaceGeneralSettingsParams, UpgradeToCorporateParams, } from '@libs/API/parameters'; -import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; +import {READ_COMMANDS, SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; import * as CurrencyUtils from '@libs/CurrencyUtils'; import DateUtils from '@libs/DateUtils'; import * as ErrorUtils from '@libs/ErrorUtils'; @@ -840,18 +841,50 @@ function addBillingCardAndRequestPolicyOwnerChange( }, ]; - const params: AddBillingCardAndRequestWorkspaceOwnerChangeParams = { - policyID, - cardNumber, - cardYear, - cardMonth, - cardCVV, - addressName, - addressZip, - currency, - }; + if (currency === CONST.PAYMENT_CARD_CURRENCY.GBP) { + const params: AddPaymentCardParams = { + cardNumber, + cardYear, + cardMonth, + cardCVV, + addressName, + addressZip, + currency, + isP2PDebitCard: false, + }; + // eslint-disable-next-line rulesdir/no-api-side-effects-method + API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.ADD_PAYMENT_CARD_GBP, params).then((response) => { + if (response?.jsonCode !== CONST.JSON_CODE.SUCCESS) { + return; + } + // We are using this onyx key to open Modal and preview iframe. Potentially we can save the whole object which come from side effect + Onyx.set(ONYXKEYS.VERIFY_3DS_SUBSCRIPTION, (response as {authenticationLink: string}).authenticationLink); + }); + } else { + const params: AddBillingCardAndRequestWorkspaceOwnerChangeParams = { + policyID, + cardNumber, + cardYear, + cardMonth, + cardCVV, + addressName, + addressZip, + currency, + }; + // eslint-disable-next-line rulesdir/no-multiple-api-calls + API.write(WRITE_COMMANDS.ADD_BILLING_CARD_AND_REQUEST_WORKSPACE_OWNER_CHANGE, params, {optimisticData, successData, failureData}); + } +} - API.write(WRITE_COMMANDS.ADD_BILLING_CARD_AND_REQUEST_WORKSPACE_OWNER_CHANGE, params, {optimisticData, successData, failureData}); +/** + * Properly updates the nvp_privateStripeCustomerID onyx data for 3DS payment + * + */ +function verifySetupIntentAndRequestPolicyOwnerChange(accountID: number, policyID: string) { + Onyx.merge(ONYXKEYS.POLICY_OWNERSHIP_CHANGE_CHECKS, { + [policyID]: {shouldTransferSubscription: true}, + }); + API.write(WRITE_COMMANDS.VERIFY_SETUP_INTENT_AND_REQUEST_POLICY_OWNER_CHANGE, {accountID, policyID}); } /** @@ -4976,6 +5009,7 @@ export { updateCompanyCardName, setCompanyCardExportAccount, clearCompanyCardErrorField, + verifySetupIntentAndRequestPolicyOwnerChange, }; export type {NewCustomUnit}; From ae7234603d6a68a51eb88dc7276e9a76213f40a8 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Wed, 18 Sep 2024 20:43:54 +0200 Subject: [PATCH 02/17] add new parameters for setupIntent --- src/libs/API/parameters/index.ts | 1 + src/libs/API/types.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 97a5ddadf7c9..c8f815920fd6 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -2,6 +2,7 @@ export type {default as ActivatePhysicalExpensifyCardParams} from './ActivatePhy export type {default as AddNewContactMethodParams} from './AddNewContactMethodParams'; export type {default as AddPaymentCardParams} from './AddPaymentCardParams'; export type {default as VerifySetupIntentParams} from './VerifySetupIntentParams'; +export type {default as VerifySetupIntentAndRequestPolicyOwnerChangeParams} from './VerifySetupIntentAndRequestPolicyOwnerChangeParams'; export type {default as AddPersonalBankAccountParams} from './AddPersonalBankAccountParams'; export type {default as RestartBankAccountSetupParams} from './RestartBankAccountSetupParams'; export type {default as AddSchoolPrincipalParams} from './AddSchoolPrincipalParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 4ccbce269948..fc6c702f589f 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -50,6 +50,7 @@ const WRITE_COMMANDS = { ADD_PAYMENT_CARD: 'AddPaymentCard', ADD_PAYMENT_CARD_GBP: 'AddPaymentCardGBP', VERIFY_SETUP_INTENT: 'User_VerifySetupIntent', + VERIFY_SETUP_INTENT_AND_REQUEST_POLICY_OWNER_CHANGE: 'verifySetupIntentAndRequestPolicyOwnerChange', TRANSFER_WALLET_BALANCE: 'TransferWalletBalance', DELETE_PAYMENT_CARD: 'DeletePaymentCard', UPDATE_PRONOUNS: 'UpdatePronouns', @@ -427,6 +428,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.ADD_PAYMENT_CARD]: Parameters.AddPaymentCardParams; [WRITE_COMMANDS.ADD_PAYMENT_CARD_GBP]: Parameters.AddPaymentCardParams; [WRITE_COMMANDS.VERIFY_SETUP_INTENT]: Parameters.VerifySetupIntentParams; + [WRITE_COMMANDS.VERIFY_SETUP_INTENT_AND_REQUEST_POLICY_OWNER_CHANGE]: Parameters.VerifySetupIntentAndRequestPolicyOwnerChangeParams; [WRITE_COMMANDS.DELETE_PAYMENT_CARD]: Parameters.DeletePaymentCardParams; [WRITE_COMMANDS.UPDATE_PRONOUNS]: Parameters.UpdatePronounsParams; [WRITE_COMMANDS.UPDATE_DISPLAY_NAME]: Parameters.UpdateDisplayNameParams; From ea4ed35e14f8cc3bd874f84b0281c7fca40dbd31 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Wed, 18 Sep 2024 20:44:14 +0200 Subject: [PATCH 03/17] new setupIntent types --- .../VerifySetupIntentAndRequestPolicyOwnerChangeParams.ts | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/libs/API/parameters/VerifySetupIntentAndRequestPolicyOwnerChangeParams.ts diff --git a/src/libs/API/parameters/VerifySetupIntentAndRequestPolicyOwnerChangeParams.ts b/src/libs/API/parameters/VerifySetupIntentAndRequestPolicyOwnerChangeParams.ts new file mode 100644 index 000000000000..091c8493aafa --- /dev/null +++ b/src/libs/API/parameters/VerifySetupIntentAndRequestPolicyOwnerChangeParams.ts @@ -0,0 +1,5 @@ +type VerifySetupIntentAndRequestPolicyOwnerChangeParams = { + accountID: number; + policyID: string; +}; +export default VerifySetupIntentAndRequestPolicyOwnerChangeParams; From e26849738b50cbd89f79bbc5c2fe03bc606f3cae Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Wed, 18 Sep 2024 20:44:36 +0200 Subject: [PATCH 04/17] update authModal to work with transfer flow --- .../Subscription/CardAuthenticationModal/index.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/pages/settings/Subscription/CardAuthenticationModal/index.tsx b/src/pages/settings/Subscription/CardAuthenticationModal/index.tsx index 6f49e9bd0508..5e0153be3dfd 100644 --- a/src/pages/settings/Subscription/CardAuthenticationModal/index.tsx +++ b/src/pages/settings/Subscription/CardAuthenticationModal/index.tsx @@ -7,14 +7,17 @@ import Modal from '@components/Modal'; import ScreenWrapper from '@components/ScreenWrapper'; import useThemeStyles from '@hooks/useThemeStyles'; import * as PaymentMethods from '@userActions/PaymentMethods'; +import * as PolicyActions from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; type CardAuthenticationModalProps = { /** Title shown in the header of the modal */ headerTitle?: string; + + policyID?: string; }; -function CardAuthenticationModal({headerTitle}: CardAuthenticationModalProps) { +function CardAuthenticationModal({headerTitle, policyID}: CardAuthenticationModalProps) { const styles = useThemeStyles(); const [authenticationLink] = useOnyx(ONYXKEYS.VERIFY_3DS_SUBSCRIPTION); const [session] = useOnyx(ONYXKEYS.SESSION); @@ -37,11 +40,15 @@ function CardAuthenticationModal({headerTitle}: CardAuthenticationModalProps) { (event: MessageEvent) => { const message = event.data; if (message === CONST.GBP_AUTHENTICATION_COMPLETE) { - PaymentMethods.verifySetupIntent(session?.accountID ?? -1, true); + if (policyID) { + PolicyActions.verifySetupIntentAndRequestPolicyOwnerChange(session?.accountID ?? -1, policyID); + } else { + PaymentMethods.verifySetupIntent(session?.accountID ?? -1, true); + } onModalClose(); } }, - [onModalClose, session?.accountID], + [onModalClose, policyID, session?.accountID], ); useEffect(() => { From 7144b125996041d1d2d012bc3b5eff9d064a15ea Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Wed, 18 Sep 2024 20:44:53 +0200 Subject: [PATCH 05/17] add auth modal to wrapper page --- .../workspace/members/WorkspaceOwnerChangeWrapperPage.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx b/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx index f6ab69b1e9c5..708cc49658a9 100644 --- a/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx +++ b/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx @@ -9,6 +9,7 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@navigation/Navigation'; import type {SettingsNavigatorParamList} from '@navigation/types'; +import CardAuthenticationModal from '@pages/settings/Subscription/CardAuthenticationModal'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyOnyxProps} from '@pages/workspace/withPolicy'; @@ -81,6 +82,10 @@ function WorkspaceOwnerChangeWrapperPage({route, policy}: WorkspaceOwnerChangeWr error={error} /> ))} + From f4753caf61577b0bb6b4e9050470ba51ba71f1f9 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Wed, 18 Sep 2024 20:45:30 +0200 Subject: [PATCH 06/17] remove hardcoded USD in add card form --- src/pages/workspace/members/WorkspaceOwnerPaymentCardForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/members/WorkspaceOwnerPaymentCardForm.tsx b/src/pages/workspace/members/WorkspaceOwnerPaymentCardForm.tsx index 91e22fd9fcd5..ab9305fa8293 100644 --- a/src/pages/workspace/members/WorkspaceOwnerPaymentCardForm.tsx +++ b/src/pages/workspace/members/WorkspaceOwnerPaymentCardForm.tsx @@ -67,7 +67,7 @@ function WorkspaceOwnerPaymentCardForm({policy}: WorkspaceOwnerPaymentCardFormPr cardCVV: values.securityCode, addressName: values.nameOnCard, addressZip: values.addressZipCode, - currency: CONST.CURRENCY.USD, + currency: values.currency, }; PolicyActions.addBillingCardAndRequestPolicyOwnerChange(policyID, cardData); From 29648964eda473eb387299d1eb273b96cb6f4b8a Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Tue, 24 Sep 2024 02:30:53 +0200 Subject: [PATCH 07/17] update setup intent behaviour --- src/libs/API/types.ts | 2 +- src/libs/actions/Policy/Policy.ts | 43 ++++++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 8094e42f1452..7317fee0828a 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -50,7 +50,7 @@ const WRITE_COMMANDS = { ADD_PAYMENT_CARD: 'AddPaymentCard', ADD_PAYMENT_CARD_GBP: 'AddPaymentCardGBP', VERIFY_SETUP_INTENT: 'User_VerifySetupIntent', - VERIFY_SETUP_INTENT_AND_REQUEST_POLICY_OWNER_CHANGE: 'verifySetupIntentAndRequestPolicyOwnerChange', + VERIFY_SETUP_INTENT_AND_REQUEST_POLICY_OWNER_CHANGE: 'VerifySetupIntentAndRequestPolicyOwnerChange', TRANSFER_WALLET_BALANCE: 'TransferWalletBalance', DELETE_PAYMENT_CARD: 'DeletePaymentCard', UPDATE_PRONOUNS: 'UpdatePronouns', diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index 87056616d4a8..10b7f50ba20b 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -878,10 +878,45 @@ function addBillingCardAndRequestPolicyOwnerChange( * */ function verifySetupIntentAndRequestPolicyOwnerChange(accountID: number, policyID: string) { - Onyx.merge(ONYXKEYS.POLICY_OWNERSHIP_CHANGE_CHECKS, { - [policyID]: {shouldTransferSubscription: true}, - }); - API.write(WRITE_COMMANDS.VERIFY_SETUP_INTENT_AND_REQUEST_POLICY_OWNER_CHANGE, {accountID, policyID}); + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + errorFields: null, + isLoading: true, + isChangeOwnerSuccessful: false, + isChangeOwnerFailed: false, + }, + }, + ]; + + const successData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + isLoading: false, + isChangeOwnerSuccessful: true, + isChangeOwnerFailed: false, + owner: sessionEmail, + ownerAccountID: sessionAccountID, + }, + }, + ]; + + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + isLoading: false, + isChangeOwnerSuccessful: false, + isChangeOwnerFailed: true, + }, + }, + ]; + API.write(WRITE_COMMANDS.VERIFY_SETUP_INTENT_AND_REQUEST_POLICY_OWNER_CHANGE, {accountID, policyID}, {optimisticData, successData, failureData}); } /** From db8270e15aa3e4cfde700441c9fc7b4653ada2f5 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Wed, 25 Sep 2024 21:25:32 +0200 Subject: [PATCH 08/17] render card form for error with SCA --- .../workspace/members/WorkspaceOwnerChangeWrapperPage.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx b/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx index 708cc49658a9..b3ea6c2716e5 100644 --- a/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx +++ b/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx @@ -1,6 +1,7 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React, {useEffect} from 'react'; import {View} from 'react-native'; +import {useOnyx} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; @@ -15,6 +16,7 @@ import withPolicy from '@pages/workspace/withPolicy'; import type {WithPolicyOnyxProps} from '@pages/workspace/withPolicy'; import * as MemberActions from '@userActions/Policy/Member'; import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import WorkspaceOwnerChangeCheck from './WorkspaceOwnerChangeCheck'; @@ -25,10 +27,12 @@ type WorkspaceOwnerChangeWrapperPageProps = WithPolicyOnyxProps & StackScreenPro function WorkspaceOwnerChangeWrapperPage({route, policy}: WorkspaceOwnerChangeWrapperPageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - + const [privateStripeCustomerID] = useOnyx(ONYXKEYS.NVP_PRIVATE_STRIPE_CUSTOMER_ID); const policyID = route.params.policyID; const accountID = route.params.accountID; const error = route.params.error; + const shouldShowPaymentCardForm = + error === CONST.POLICY.OWNERSHIP_ERRORS.NO_BILLING_CARD || privateStripeCustomerID?.status === CONST.STRIPE_GBP_AUTH_STATUSES.CARD_AUTHENTICATION_REQUIRED; useEffect(() => { if (!policy || policy?.isLoading) { @@ -73,7 +77,7 @@ function WorkspaceOwnerChangeWrapperPage({route, policy}: WorkspaceOwnerChangeWr {policy?.isLoading && } {!policy?.isLoading && - (error === CONST.POLICY.OWNERSHIP_ERRORS.NO_BILLING_CARD ? ( + (shouldShowPaymentCardForm ? ( ) : ( Date: Thu, 26 Sep 2024 00:07:21 +0200 Subject: [PATCH 09/17] add fail support, show error from the backend --- .../WorkspaceOwnerChangeWrapperPage.tsx | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx b/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx index b3ea6c2716e5..ea8d4a3c2c06 100644 --- a/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx +++ b/src/pages/workspace/members/WorkspaceOwnerChangeWrapperPage.tsx @@ -31,8 +31,8 @@ function WorkspaceOwnerChangeWrapperPage({route, policy}: WorkspaceOwnerChangeWr const policyID = route.params.policyID; const accountID = route.params.accountID; const error = route.params.error; - const shouldShowPaymentCardForm = - error === CONST.POLICY.OWNERSHIP_ERRORS.NO_BILLING_CARD || privateStripeCustomerID?.status === CONST.STRIPE_GBP_AUTH_STATUSES.CARD_AUTHENTICATION_REQUIRED; + const isAuthRequired = privateStripeCustomerID?.status === CONST.STRIPE_GBP_AUTH_STATUSES.CARD_AUTHENTICATION_REQUIRED; + const shouldShowPaymentCardForm = error === CONST.POLICY.OWNERSHIP_ERRORS.NO_BILLING_CARD || isAuthRequired; useEffect(() => { if (!policy || policy?.isLoading) { @@ -76,16 +76,14 @@ function WorkspaceOwnerChangeWrapperPage({route, policy}: WorkspaceOwnerChangeWr /> {policy?.isLoading && } - {!policy?.isLoading && - (shouldShowPaymentCardForm ? ( - - ) : ( - - ))} + {shouldShowPaymentCardForm && } + {!policy?.isLoading && !shouldShowPaymentCardForm && ( + + )} Date: Thu, 26 Sep 2024 23:41:35 +0200 Subject: [PATCH 10/17] use sessionAccountID --- .../VerifySetupIntentAndRequestPolicyOwnerChangeParams.ts | 1 - src/libs/actions/Policy/Policy.ts | 4 ++-- .../settings/Subscription/CardAuthenticationModal/index.tsx | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libs/API/parameters/VerifySetupIntentAndRequestPolicyOwnerChangeParams.ts b/src/libs/API/parameters/VerifySetupIntentAndRequestPolicyOwnerChangeParams.ts index 091c8493aafa..d17ca25283a6 100644 --- a/src/libs/API/parameters/VerifySetupIntentAndRequestPolicyOwnerChangeParams.ts +++ b/src/libs/API/parameters/VerifySetupIntentAndRequestPolicyOwnerChangeParams.ts @@ -1,5 +1,4 @@ type VerifySetupIntentAndRequestPolicyOwnerChangeParams = { - accountID: number; policyID: string; }; export default VerifySetupIntentAndRequestPolicyOwnerChangeParams; diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index 10b7f50ba20b..ef3065f4f867 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -877,7 +877,7 @@ function addBillingCardAndRequestPolicyOwnerChange( * Properly updates the nvp_privateStripeCustomerID onyx data for 3DS payment * */ -function verifySetupIntentAndRequestPolicyOwnerChange(accountID: number, policyID: string) { +function verifySetupIntentAndRequestPolicyOwnerChange(policyID: string) { const optimisticData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, @@ -916,7 +916,7 @@ function verifySetupIntentAndRequestPolicyOwnerChange(accountID: number, policyI }, }, ]; - API.write(WRITE_COMMANDS.VERIFY_SETUP_INTENT_AND_REQUEST_POLICY_OWNER_CHANGE, {accountID, policyID}, {optimisticData, successData, failureData}); + API.write(WRITE_COMMANDS.VERIFY_SETUP_INTENT_AND_REQUEST_POLICY_OWNER_CHANGE, {sessionAccountID, policyID}, {optimisticData, successData, failureData}); } /** diff --git a/src/pages/settings/Subscription/CardAuthenticationModal/index.tsx b/src/pages/settings/Subscription/CardAuthenticationModal/index.tsx index 5e0153be3dfd..b323c668b0b5 100644 --- a/src/pages/settings/Subscription/CardAuthenticationModal/index.tsx +++ b/src/pages/settings/Subscription/CardAuthenticationModal/index.tsx @@ -41,7 +41,7 @@ function CardAuthenticationModal({headerTitle, policyID}: CardAuthenticationModa const message = event.data; if (message === CONST.GBP_AUTHENTICATION_COMPLETE) { if (policyID) { - PolicyActions.verifySetupIntentAndRequestPolicyOwnerChange(session?.accountID ?? -1, policyID); + PolicyActions.verifySetupIntentAndRequestPolicyOwnerChange(policyID); } else { PaymentMethods.verifySetupIntent(session?.accountID ?? -1, true); } From a123f2e4e19666646cfe3a8ebba18f8c73424bdf Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Fri, 27 Sep 2024 14:41:46 +0200 Subject: [PATCH 11/17] update show of transfer owner --- .../members/WorkspaceMemberDetailsPage.tsx | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx b/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx index 41071f2c6d75..fe84ed4489f0 100644 --- a/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx +++ b/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx @@ -1,4 +1,5 @@ import type {StackScreenProps} from '@react-navigation/stack'; +import isEmpty from 'lodash/isEmpty'; import React, {useCallback, useEffect, useMemo, useState} from 'react'; import {View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; @@ -24,6 +25,7 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import * as CardUtils from '@libs/CardUtils'; import * as CurrencyUtils from '@libs/CurrencyUtils'; +import getPlatform from '@libs/getPlatform'; import * as PolicyUtils from '@libs/PolicyUtils'; import Navigation from '@navigation/Navigation'; import type {SettingsNavigatorParamList} from '@navigation/types'; @@ -80,6 +82,11 @@ function WorkspaceMemberDetailsPage({personalDetails, policy, route}: WorkspaceM const policyOwnerDisplayName = ownerDetails.displayName ?? policy?.owner ?? ''; const companyCards = CardUtils.getMemberCards(policy, allCardsList, accountID); + // To render correctly transfer owner button + const [fundList] = useOnyx(ONYXKEYS.FUND_LIST, {initialValue: {}}); + const isNative = getPlatform() === CONST.PLATFORM.IOS || getPlatform() === CONST.PLATFORM.ANDROID; + const shouldShowTransferButton = !isNative || (isNative && !isEmpty(fundList)); + // TODO: for now enabled for testing purposes. Change this to check for the actual multiple feeds when API is ready const hasMultipleFeeds = policy?.areCompanyCardsEnabled; @@ -240,14 +247,16 @@ function WorkspaceMemberDetailsPage({personalDetails, policy, route}: WorkspaceM )} {isSelectedMemberOwner && isCurrentUserAdmin && !isCurrentUserOwner ? ( -