Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ec123a9
Add refresh card feed connection route and screen
fedirjh Mar 21, 2026
2f3cfa1
Add translations for assigning new cards in English and Spanish
fedirjh Mar 21, 2026
f040967
Add RefreshCardFeedConnectionPage and integrate with WorkspaceCompany…
fedirjh Mar 22, 2026
577e492
Enhance card assignment flow with refresh state management
fedirjh Mar 22, 2026
a6a1eec
Refactor RefreshCardFeedConnectionPage to improve refresh state handling
fedirjh Mar 22, 2026
f591523
Enhance card connection components with title prop support
fedirjh Mar 22, 2026
3f800d3
Enhance RefreshCardFeedConnectionPage with feed expiration handling
fedirjh Mar 22, 2026
5172537
Add unit tests for RefreshCardFeedConnectionPage
fedirjh Mar 22, 2026
5a684b3
Add WorkspaceCompanyCardsVerifyAccountPage and related routing logic
fedirjh Mar 22, 2026
1c588a4
Enhance company card feed functionality with new refresh logic
fedirjh Mar 22, 2026
1dfd79a
Refactor RefreshCardFeedConnectionPage and WorkspaceCompanyCardsSetti…
fedirjh Mar 22, 2026
f7fb565
Refactor imports and enhance test structure for RefreshCardFeedConnec…
fedirjh Mar 22, 2026
ed6dbad
Merge branch 'Expensify:main' into sync-feed-cards
fedirjh Mar 23, 2026
19ae51a
Add 'assignNewCards' feature to multiple language files with titles a…
fedirjh Mar 23, 2026
08a33b7
Refactor CompanyCards actions by removing unused setFeedRefreshComple…
fedirjh Mar 23, 2026
2e377ba
Remove unused setFeedRefreshComplete function from RefreshCardFeedCon…
fedirjh Mar 23, 2026
21ff93a
Merge branch 'Expensify:main' into sync-feed-cards
fedirjh Mar 23, 2026
aaab346
Refactor mock components in RefreshCardFeedConnectionPageTest to dyna…
fedirjh Mar 23, 2026
66c6c15
Add NotFoundPage component and validation for direct feed in RefreshC…
fedirjh Mar 25, 2026
4fb7c1f
Merge branch 'Expensify:main' into sync-feed-cards
fedirjh Mar 25, 2026
2f18dd5
Refactor imports in RefreshCardFeedConnectionPage to streamline code …
fedirjh Mar 25, 2026
fa3d94e
Enhance validation in RefreshCardFeedConnectionPage by adding current…
fedirjh Mar 25, 2026
361bf96
Merge branch 'Expensify:main' into sync-feed-cards
fedirjh Mar 25, 2026
50a1db5
Merge branch 'Expensify:main' into sync-feed-cards
fedirjh Mar 26, 2026
0b8b7da
Enhance RefreshCardFeedConnectionPage tests to include NotFoundPage r…
fedirjh Mar 26, 2026
c6ec064
Add tests for ROUTES helper functions in RefreshCardFeedConnectionPag…
fedirjh Mar 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2476,6 +2476,15 @@ const ROUTES = {
route: 'workspaces/:policyID/company-cards/:feed/broken-card-feed-connection',
getRoute: (policyID: string, feed: CompanyCardFeedWithDomainID) => `workspaces/${policyID}/company-cards/${encodeURIComponent(feed)}/broken-card-feed-connection` as const,
},
WORKSPACE_COMPANY_CARDS_REFRESH_CARD_FEED_CONNECTION: {
route: 'workspaces/:policyID/company-cards/:feed/refresh-card-feed-connection',
getRoute: (policyID: string, feed: CompanyCardFeedWithDomainID) => `workspaces/${policyID}/company-cards/${encodeURIComponent(feed)}/refresh-card-feed-connection` as const,
},
WORKSPACE_COMPANY_CARDS_VERIFY_ACCOUNT: {
route: `workspaces/:policyID/company-cards/${VERIFY_ACCOUNT}`,
getRoute: (policyID: string, feed?: CompanyCardFeedWithDomainID) =>
feed ? (`workspaces/${policyID}/company-cards/${VERIFY_ACCOUNT}?feed=${encodeURIComponent(feed)}` as const) : (`workspaces/${policyID}/company-cards/${VERIFY_ACCOUNT}` as const),
},
WORKSPACE_COMPANY_CARDS_ASSIGN_CARD_ASSIGNEE: {
route: 'workspaces/:policyID/company-cards/:feed/assign-card/:cardID/assignee',
getRoute: (params: WorkspaceCompanyCardsAssignCardParams, backTo?: string) =>
Expand Down
2 changes: 2 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,8 @@ const SCREENS = {
PROFILE: 'Workspace_Overview',
COMPANY_CARDS: 'Workspace_CompanyCards',
COMPANY_CARDS_BROKEN_CARD_FEED_CONNECTION: 'Workspace_CompanyCards_BrokenCardFeedConnection',
COMPANY_CARDS_REFRESH_CARD_FEED_CONNECTION: 'Workspace_CompanyCards_RefreshCardFeedConnection',
COMPANY_CARDS_VERIFY_ACCOUNT: 'Workspace_CompanyCards_VerifyAccount',
COMPANY_CARDS_ASSIGN_CARD_ASSIGNEE: 'Workspace_CompanyCards_AssignCard_Assignee',
COMPANY_CARDS_ASSIGN_CARD_BANK_CONNECTION: 'Workspace_CompanyCards_AssignCard_Bank_Connection',
COMPANY_CARDS_ASSIGN_CARD_PLAID_CONNECTION: 'Workspace_CompanyCards_AssignCard_Plaid_Connection',
Expand Down
1 change: 1 addition & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5130,6 +5130,7 @@ _Für ausführlichere Anweisungen [besuchen Sie unsere Hilfeseite](${CONST.NETSU
flipAmountSign: 'Betragsvorzeichen umkehren',
importButton: 'Transaktionen importieren',
},
assignNewCards: {title: 'Neue Karten zuweisen', description: 'Holen Sie die neuesten Karten zum Zuweisen von Ihrer Bank'},
},
expensifyCard: {
issueAndManageCards: 'Geben Sie Expensify Karten aus und verwalten Sie sie',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5124,6 +5124,10 @@ const translations = {
flipAmountSign: 'Flip amount sign',
importButton: 'Import transactions',
},
assignNewCards: {
title: 'Assign new cards',
description: 'Get the latest cards to assign from your bank',
},
},
expensifyCard: {
issueAndManageCards: 'Issue and manage your Expensify Cards',
Expand Down
4 changes: 4 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5008,6 +5008,10 @@ ${amount} para ${merchant} - ${date}`,
flipAmountSign: 'Invertir el signo del monto',
importButton: 'Importar transacciones',
},
assignNewCards: {
title: 'Asignar nuevas tarjetas',
description: 'Obtén las últimas tarjetas para asignar desde tu banco',
},
},
expensifyCard: {
issueAndManageCards: 'Emitir y gestionar Tarjetas Expensify',
Expand Down
1 change: 1 addition & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5141,6 +5141,7 @@ _Pour des instructions plus détaillées, [visitez notre site d’aide](${CONST.
flipAmountSign: 'Inverser le signe du montant',
importButton: 'Importer des transactions',
},
assignNewCards: {title: 'Assigner de nouvelles cartes', description: 'Obtenez les dernières cartes à assigner depuis votre banque'},
},
expensifyCard: {
issueAndManageCards: 'Émettre et gérer vos Cartes Expensify',
Expand Down
1 change: 1 addition & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5112,6 +5112,7 @@ _Per istruzioni più dettagliate, [visita il nostro sito di assistenza](${CONST.
flipAmountSign: 'Inverti segno importo',
importButton: 'Importa transazioni',
},
assignNewCards: {title: 'Assegna nuove carte', description: 'Ottieni le ultime carte da assegnare dalla tua banca'},
},
expensifyCard: {
issueAndManageCards: 'Emetti e gestisci le tue Carte Expensify',
Expand Down
1 change: 1 addition & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5064,6 +5064,7 @@ _詳しい手順については、[ヘルプサイトをご覧ください](${CO
flipAmountSign: '金額の符号を反転',
importButton: '取引をインポート',
},
assignNewCards: {title: '新しいカードを割り当てる', description: '銀行から割り当て可能な最新のカードを取得します'},
},
expensifyCard: {
issueAndManageCards: 'Expensify カードを発行して管理する',
Expand Down
1 change: 1 addition & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5103,6 +5103,7 @@ _Voor meer gedetailleerde instructies, [bezoek onze help-site](${CONST.NETSUITE_
flipAmountSign: 'Teken van bedrag omdraaien',
importButton: 'Transacties importeren',
},
assignNewCards: {title: 'Nieuwe kaarten toewijzen', description: 'Haal de nieuwste kaarten op om toe te wijzen vanuit je bank'},
},
expensifyCard: {
issueAndManageCards: 'Geef Expensify Kaarten uit en beheer ze',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5095,6 +5095,7 @@ _Aby uzyskać bardziej szczegółowe instrukcje, [odwiedź naszą stronę pomocy
flipAmountSign: 'Odwróć znak kwoty',
importButton: 'Importuj transakcje',
},
assignNewCards: {title: 'Przydziel nowe karty', description: 'Pobierz z banku najnowsze karty do przypisania'},
},
expensifyCard: {
issueAndManageCards: 'Wydawaj i zarządzaj Kartami Expensify',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5095,6 +5095,7 @@ _Para instruções mais detalhadas, [visite nossa central de ajuda](${CONST.NETS
flipAmountSign: 'Inverter sinal do valor',
importButton: 'Importar transações',
},
assignNewCards: {title: 'Atribuir novos cartões', description: 'Obtenha do seu banco os cartões mais recentes para atribuir'},
},
expensifyCard: {
issueAndManageCards: 'Emita e gerencie seus Cartões Expensify',
Expand Down
1 change: 1 addition & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4984,6 +4984,7 @@ _如需更详细的说明,请[访问我们的帮助网站](${CONST.NETSUITE_IM
flipAmountSign: '翻转金额符号',
importButton: '导入交易',
},
assignNewCards: {title: '分配新卡', description: '从您的银行获取可分配的最新银行卡'},
},
expensifyCard: {
issueAndManageCards: '发放并管理您的 Expensify 卡',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,8 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
[SCREENS.WORKSPACE.INVOICES_COMPANY_WEBSITE]: () => require<ReactComponentModule>('../../../../pages/workspace/invoices/WorkspaceInvoicingDetailsWebsite').default,
[SCREENS.WORKSPACE.INVOICES_VERIFY_ACCOUNT]: () => require<ReactComponentModule>('../../../../pages/workspace/invoices/WorkspaceInvoicesVerifyAccountPage').default,
[SCREENS.WORKSPACE.COMPANY_CARDS_BROKEN_CARD_FEED_CONNECTION]: () => require<ReactComponentModule>('../../../../pages/workspace/companyCards/BrokenCardFeedConnectionPage').default,
[SCREENS.WORKSPACE.COMPANY_CARDS_REFRESH_CARD_FEED_CONNECTION]: () => require<ReactComponentModule>('../../../../pages/workspace/companyCards/RefreshCardFeedConnectionPage').default,
[SCREENS.WORKSPACE.COMPANY_CARDS_VERIFY_ACCOUNT]: () => require<ReactComponentModule>('../../../../pages/workspace/companyCards/WorkspaceCompanyCardsVerifyAccountPage').default,
[SCREENS.WORKSPACE.COMPANY_CARDS_ASSIGN_CARD_ASSIGNEE]: () => require<ReactComponentModule>('../../../../pages/workspace/companyCards/assignCard/AssigneeStep').default,
[SCREENS.WORKSPACE.COMPANY_CARDS_ASSIGN_CARD_CARD_SELECTION]: () => require<ReactComponentModule>('../../../../pages/workspace/companyCards/assignCard/CardSelectionStep').default,
[SCREENS.WORKSPACE.COMPANY_CARDS_ASSIGN_CARD_TRANSACTION_START_DATE]: () =>
Expand Down
6 changes: 6 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,12 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
[SCREENS.WORKSPACE.COMPANY_CARDS_BROKEN_CARD_FEED_CONNECTION]: {
path: ROUTES.WORKSPACE_COMPANY_CARDS_BROKEN_CARD_FEED_CONNECTION.route,
},
[SCREENS.WORKSPACE.COMPANY_CARDS_REFRESH_CARD_FEED_CONNECTION]: {
path: ROUTES.WORKSPACE_COMPANY_CARDS_REFRESH_CARD_FEED_CONNECTION.route,
},
[SCREENS.WORKSPACE.COMPANY_CARDS_VERIFY_ACCOUNT]: {
path: ROUTES.WORKSPACE_COMPANY_CARDS_VERIFY_ACCOUNT.route,
},
[SCREENS.WORKSPACE.COMPANY_CARDS_ASSIGN_CARD_ASSIGNEE]: {
path: ROUTES.WORKSPACE_COMPANY_CARDS_ASSIGN_CARD_ASSIGNEE.route,
},
Expand Down
10 changes: 10 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,16 @@ type SettingsNavigatorParamList = {
// eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md
backTo?: Routes;
};
[SCREENS.WORKSPACE.COMPANY_CARDS_REFRESH_CARD_FEED_CONNECTION]: {
policyID: string;
feed: CompanyCardFeedWithDomainID;
};
[SCREENS.WORKSPACE.COMPANY_CARDS_VERIFY_ACCOUNT]: {
policyID: string;

/** Present when verifying before a feed refresh; absent when verifying before adding a new feed */
feed?: CompanyCardFeedWithDomainID;
};
[SCREENS.WORKSPACE.COMPANY_CARDS_ASSIGN_CARD_ASSIGNEE]: {
policyID: string;
feed: CompanyCardFeedWithDomainID;
Expand Down
38 changes: 34 additions & 4 deletions src/libs/actions/CompanyCards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ import type {
} from '@libs/API/parameters';
import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
import * as CardUtils from '@libs/CardUtils';
import {getCardFeedWithDomainID} from '@libs/CardUtils';
import {getCardFeedWithDomainID, getPlaidCountry, getPlaidInstitutionId} from '@libs/CardUtils';
import * as ErrorUtils from '@libs/ErrorUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
import * as ReportUtils from '@libs/ReportUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Card, Policy} from '@src/types/onyx';
import ROUTES from '@src/ROUTES';
import type {Card, CurrencyList, Policy} from '@src/types/onyx';
import type {AssignCard, AssignCardData} from '@src/types/onyx/AssignCard';
import type {
AddNewCardFeedData,
Expand All @@ -48,8 +50,8 @@ type AddNewCompanyCardFlowData = {
data?: Partial<AddNewCardFeedData>;
};

function setAssignCardStepAndData({cardToAssign, isEditing, currentStep}: Partial<AssignCard>) {
Onyx.merge(ONYXKEYS.ASSIGN_CARD, {cardToAssign, isEditing, currentStep});
function setAssignCardStepAndData({cardToAssign, isEditing, currentStep, isRefreshing}: Partial<AssignCard>) {
Onyx.merge(ONYXKEYS.ASSIGN_CARD, {cardToAssign, isEditing, currentStep, isRefreshing});
}

function setTransactionStartDate(startDate: string) {
Expand Down Expand Up @@ -1061,6 +1063,32 @@ function clearErrorField(bankName: CompanyCardFeedWithNumber, domainAccountID: n
});
}

/**
* Seeds the Onyx state required before entering the card feed refresh flow.
* Used as the onValidationSuccess callback in the verify account page, where
* VerifyAccountPageBase handles navigation separately via navigateForwardTo.
*/
function seedCardFeedRefresh(feed: CompanyCardFeedWithDomainID, outputCurrency?: string, currencyList?: CurrencyList, countryByIp?: string) {
const isPlaid = !!getPlaidInstitutionId(feed);
const currentStep = isPlaid ? CONST.COMPANY_CARD.STEP.PLAID_CONNECTION : CONST.COMPANY_CARD.STEP.BANK_CONNECTION;

if (isPlaid) {
const country = getPlaidCountry(outputCurrency, currencyList, countryByIp);
setAddNewCompanyCardStepAndData({data: {selectedCountry: country}});
}

setAssignCardStepAndData({currentStep, isRefreshing: true});
}

/** Seeds the Onyx state and navigates to the card feed refresh flow. */
function startCardFeedRefresh(policyID: string, feed: CompanyCardFeedWithDomainID, outputCurrency?: string, currencyList?: CurrencyList, countryByIp?: string) {
seedCardFeedRefresh(feed, outputCurrency, currencyList, countryByIp);

Navigation.setNavigationActionToMicrotaskQueue(() => {
Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARDS_REFRESH_CARD_FEED_CONNECTION.getRoute(policyID, feed));
});
}

export {
setWorkspaceCompanyCardFeedName,
deleteWorkspaceCompanyCardFeed,
Expand All @@ -1086,4 +1114,6 @@ export {
setFeedStatementPeriodEndDay,
clearErrorField,
clearAssignCardErrors,
seedCardFeedRefresh,
startCardFeedRefresh,
};
19 changes: 18 additions & 1 deletion src/libs/actions/Plaid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,24 @@ function importPlaidAccounts(
plaidAccessToken,
};

API.write(WRITE_COMMANDS.IMPORT_PLAID_ACCOUNTS, parameters);
const onyxData = {
successData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ASSIGN_CARD,
value: {isRefreshing: null},
},
],
failureData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ASSIGN_CARD,
value: {isRefreshing: null},
},
],
};

API.write(WRITE_COMMANDS.IMPORT_PLAID_ACCOUNTS, parameters, onyxData);
}

export {openPlaidBankAccountSelector, openPlaidBankLogin, openPlaidCompanyCardLogin, importPlaidAccounts};
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ type BankConnectionProps = {

/** Route params for add new card flow */
route?: PlatformStackRouteProp<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.COMPANY_CARDS_BANK_CONNECTION>;

/** Title of the header */
title?: string;
};

function BankConnection({policyID: policyIDFromProps, feed, route}: BankConnectionProps) {
function BankConnection({policyID: policyIDFromProps, feed, route, title}: BankConnectionProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const webViewRef = useRef<WebView>(null);
Expand Down Expand Up @@ -176,7 +179,7 @@ function BankConnection({policyID: policyIDFromProps, feed, route}: BankConnecti
shouldEnableMaxHeight
>
<HeaderWithBackButton
title={headerTitle}
title={title ?? headerTitle}
onBackButtonPress={handleBackButtonPress}
/>
<FullPageOfflineBlockingView addBottomSafeAreaPadding>
Expand Down
7 changes: 5 additions & 2 deletions src/pages/workspace/companyCards/BankConnection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ type BankConnectionProps = {

/** Route params for add new card flow */
route?: PlatformStackRouteProp<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.COMPANY_CARDS_BANK_CONNECTION>;

/** Title of the header */
title?: string;
};

function BankConnection({policyID: policyIDFromProps, feed, route}: BankConnectionProps) {
function BankConnection({policyID: policyIDFromProps, feed, route, title}: BankConnectionProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const [addNewCard] = useOnyx(ONYXKEYS.ADD_NEW_COMPANY_CARD);
Expand Down Expand Up @@ -236,7 +239,7 @@ function BankConnection({policyID: policyIDFromProps, feed, route}: BankConnecti
enableEdgeToEdgeBottomSafeAreaPadding
>
<HeaderWithBackButton
title={headerTitle}
title={title ?? headerTitle}
onBackButtonPress={handleBackButtonPress}
/>
<FullPageOfflineBlockingView addBottomSafeAreaPadding>{getContent()}</FullPageOfflineBlockingView>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import React, {useEffect} from 'react';
import useCardFeeds from '@hooks/useCardFeeds';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import usePrevious from '@hooks/usePrevious';
import {isDirectFeed} from '@libs/CardUtils';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import type {SettingsNavigatorParamList} from '@navigation/types';
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
import LoadingPage from '@pages/LoadingPage';
import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPolicyAndFullscreenLoading';
import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading';
import {clearAssignCardStepAndData} from '@userActions/CompanyCards';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import PlaidConnectionStep from './addNew/PlaidConnectionStep';
import BankConnection from './BankConnection';

type RefreshCardFeedConnectionPageProps = PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.COMPANY_CARDS_REFRESH_CARD_FEED_CONNECTION> &
WithPolicyAndFullscreenLoadingProps;

function RefreshCardFeedConnectionPage({route, policy}: RefreshCardFeedConnectionPageProps) {
const feed = route.params?.feed;
const policyID = policy?.id;

const {translate} = useLocalize();

const [assignCard] = useOnyx(ONYXKEYS.ASSIGN_CARD);
const currentStep = assignCard?.currentStep;
const isRefreshing = assignCard?.isRefreshing;
const prevIsRefreshing = usePrevious(isRefreshing);
const title = translate('workspace.companyCards.assignNewCards.title');

const [cardFeeds] = useCardFeeds(policyID);
const feedExpiration = feed ? cardFeeds?.[feed]?.expiration : undefined;
const prevFeedExpiration = usePrevious(feedExpiration);

useEffect(() => {
return () => {
clearAssignCardStepAndData();
};
}, []);

// Plaid feeds: isRefreshing is cleared by importPlaidAccounts successData
useEffect(() => {
if (prevIsRefreshing !== true || isRefreshing) {
return;
}
Navigation.closeRHPFlow();
}, [prevIsRefreshing, isRefreshing]);

// OAuth feeds: expiration updates after bank re-authentication completes
useEffect(() => {
if (prevFeedExpiration === undefined || prevFeedExpiration === feedExpiration || !isRefreshing) {
return;
}
Navigation.closeRHPFlow();
}, [prevFeedExpiration, feedExpiration, isRefreshing]);
Comment thread
fedirjh marked this conversation as resolved.
Resolved

if (!isDirectFeed(feed) || !cardFeeds?.[feed] || !currentStep) {
return <NotFoundPage />;
}

switch (currentStep) {
case CONST.COMPANY_CARD.STEP.BANK_CONNECTION:
return (
<BankConnection
policyID={policyID}
feed={feed}
title={title}
/>
);
case CONST.COMPANY_CARD.STEP.PLAID_CONNECTION:
return (
<PlaidConnectionStep
feed={feed}
policyID={policyID}
title={title}
/>
);
default:
return <LoadingPage title={title} />;
}
}

export default withPolicyAndFullscreenLoading(RefreshCardFeedConnectionPage);
Loading
Loading