Skip to content

Commit 442336b

Browse files
authored
Merge pull request #89208 from Expensify/lucien/fix-thirdParty-connectionFlow
Update 3rd Party Connection Flow
2 parents 3f5e62c + 8452cad commit 442336b

17 files changed

Lines changed: 47 additions & 243 deletions

src/CONST/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4145,8 +4145,6 @@ const CONST = {
41454145
AMEX_CUSTOM_FEED: 'AmexCustomFeed',
41464146
SELECT_COUNTRY: 'SelectCountry',
41474147
PLAID_CONNECTION: 'PlaidConnection',
4148-
SELECT_STATEMENT_CLOSE_DATE: 'SelectStatementCloseDate',
4149-
SELECT_DIRECT_STATEMENT_CLOSE_DATE: 'SelectDirectStatementCloseDate',
41504148
IMPORT_FROM_FILE: 'ImportFromFile',
41514149
},
41524150
CARD_TYPE: {

src/hooks/useAssignCard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ function useInitialAssignCardStep({policyID, selectedFeed}: UseInitialAssignCard
175175
// Refetch plaid card list
176176
if (!isFeedExpired && plaidAccessToken && !hasImportedPlaidAccounts.current) {
177177
const country = feedData?.country ?? '';
178-
importPlaidAccounts('', selectedFeed, '', country, getDomainNameForPolicy(policyID), '', undefined, undefined, plaidAccessToken);
178+
importPlaidAccounts('', selectedFeed, '', country, getDomainNameForPolicy(policyID), '', plaidAccessToken);
179179
hasImportedPlaidAccounts.current = true;
180180
}
181181

src/hooks/useCardFeeds.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ import useWorkspaceAccountID from './useWorkspaceAccountID';
2020
* 1. Combined workspace and domain card feeds specific to the given policyID (or `undefined` if unavailable).
2121
* 2. The result metadata from the Onyx collection fetch.
2222
* 3. Card feeds specific to the given policyID (or `undefined` if unavailable).
23+
* 4. Card feed status by domain ID.
24+
* 5. Workspace account ID for the policy.
2325
*/
24-
const useCardFeeds = (policyID: string | undefined): [CombinedCardFeeds | undefined, ResultMetadata<OnyxCollection<CardFeeds>>, CardFeeds | undefined, CardFeedsStatusByDomainID] => {
26+
const useCardFeeds = (policyID: string | undefined): [CombinedCardFeeds | undefined, ResultMetadata<OnyxCollection<CardFeeds>>, CardFeeds | undefined, CardFeedsStatusByDomainID, number] => {
2527
const workspaceAccountID = useWorkspaceAccountID(policyID);
2628
const [allFeeds, allFeedsResult] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER);
2729
const feedKeysWithCards = useFeedKeysWithAssignedCards();
@@ -61,7 +63,7 @@ const useCardFeeds = (policyID: string | undefined): [CombinedCardFeeds | undefi
6163

6264
const workspaceCardFeedsStatus = getWorkspaceCardFeedsStatus(allFeeds);
6365

64-
return [workspaceFeeds, allFeedsResult, defaultFeed, workspaceCardFeedsStatus];
66+
return [workspaceFeeds, allFeedsResult, defaultFeed, workspaceCardFeedsStatus, workspaceAccountID];
6567
};
6668

6769
export default useCardFeeds;

src/hooks/useImportPlaidAccounts.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ export default function useImportPlaidAccounts(policyID?: string) {
1313
const plaidFeedName = addNewCard?.data?.plaidConnectedFeedName ?? assignCard?.cardToAssign?.plaidConnectedFeedName;
1414
const plaidAccounts = addNewCard?.data?.plaidAccounts ?? assignCard?.cardToAssign?.plaidAccounts;
1515
const country = addNewCard?.data?.selectedCountry;
16-
const statementPeriodEnd = addNewCard?.data?.statementPeriodEnd;
17-
const statementPeriodEndDay = addNewCard?.data?.statementPeriodEndDay;
1816

1917
return useCallback(() => {
2018
if (!policyID || !plaidToken || !plaidFeed || !plaidFeedName || !country || !plaidAccounts?.length) {
2119
return;
2220
}
23-
importPlaidAccounts(plaidToken, plaidFeed, plaidFeedName, country, getDomainNameForPolicy(policyID), JSON.stringify(plaidAccounts), statementPeriodEnd, statementPeriodEndDay, '');
24-
}, [statementPeriodEnd, statementPeriodEndDay, country, plaidAccounts, plaidFeed, plaidFeedName, plaidToken, policyID]);
21+
importPlaidAccounts(plaidToken, plaidFeed, plaidFeedName, country, getDomainNameForPolicy(policyID), JSON.stringify(plaidAccounts), '');
22+
}, [country, plaidAccounts, plaidFeed, plaidFeedName, plaidToken, policyID]);
2523
}

src/hooks/useIsBlockedToAddFeed.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import usePolicy from './usePolicy';
1919
*/
2020
function useIsBlockedToAddFeed(policyID?: string) {
2121
const policy = usePolicy(policyID);
22-
const [cardFeeds, allFeedsResult, defaultFeed] = useCardFeeds(policyID);
22+
const [cardFeeds, allFeedsResult, defaultFeed, , workspaceAccountID] = useCardFeeds(policyID);
2323
const companyFeeds = getCompanyFeeds(cardFeeds, true);
2424
const isCollect = isCollectPolicy(policy);
2525
const isAllFeedsResultLoading = isLoadingOnyxValue(allFeedsResult);
@@ -39,6 +39,8 @@ function useIsBlockedToAddFeed(policyID?: string) {
3939
return {
4040
isBlockedToAddNewFeeds: isCollect && !isLoading && prevCompanyFeedsLength >= 1,
4141
isAllFeedsResultLoading: isCollect && (isLoading || isAllFeedsResultLoading),
42+
cardFeeds,
43+
workspaceAccountID,
4244
};
4345
}
4446

src/libs/API/parameters/ImportPlaidAccountsParams.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
import type {StatementPeriodEnd, StatementPeriodEndDay} from '@src/types/onyx/CardFeeds';
2-
31
type ImportPlaidAccountsParams = {
42
publicToken: string;
53
feed: string;
64
feedName: string;
75
country: string;
86
domainName: string;
97
plaidAccounts: string;
10-
statementPeriodEnd?: StatementPeriodEnd;
11-
statementPeriodEndDay?: StatementPeriodEndDay;
128
plaidAccessToken?: string;
139
};
1410

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import type {StatementPeriodEnd, StatementPeriodEndDay} from '@src/types/onyx/CardFeeds';
2-
31
type RequestFeedSetupParams = {
42
policyID: string;
53
feedDetails: string;
64
feedType: string;
7-
statementPeriodEnd?: StatementPeriodEnd;
8-
statementPeriodEndDay?: StatementPeriodEndDay;
95
};
106

117
export default RequestFeedSetupParams;

src/libs/actions/CompanyCards.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ function addNewCompanyCardsFeed(
180180
cardFeed: CompanyCardFeed,
181181
feedDetails: CardFeedDetails,
182182
cardFeeds: OnyxEntry<CombinedCardFeeds>,
183-
statementPeriodEnd: StatementPeriodEnd | undefined,
184-
statementPeriodEndDay: StatementPeriodEndDay | undefined,
185183
lastSelectedFeed?: CompanyCardFeedWithDomainID,
186184
) {
187185
if (!policyID) {
@@ -205,7 +203,6 @@ function addNewCompanyCardsFeed(
205203
settings: {
206204
companyCards: {
207205
[feedType]: {
208-
statementPeriodEndDay: statementPeriodEndDay ?? statementPeriodEnd ?? null,
209206
errors: null,
210207
},
211208
},
@@ -252,8 +249,6 @@ function addNewCompanyCardsFeed(
252249
.map(([key, value]) => `${key}: ${value}`)
253250
.join(', ')
254251
: '',
255-
statementPeriodEnd,
256-
statementPeriodEndDay,
257252
};
258253

259254
API.write(WRITE_COMMANDS.REQUEST_FEED_SETUP, parameters, {optimisticData, failureData, finallyData});

src/libs/actions/Plaid.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {getCompanyCardFeed} from '@libs/CardUtils';
77
import getPlaidLinkTokenParameters from '@libs/getPlaidLinkTokenParameters';
88
import CONST from '@src/CONST';
99
import ONYXKEYS from '@src/ONYXKEYS';
10-
import type {CardFeedWithDomainID, CardFeedWithNumber, CompanyCardFeedWithDomainID, StatementPeriodEnd, StatementPeriodEndDay} from '@src/types/onyx/CardFeeds';
10+
import type {CardFeedWithDomainID, CardFeedWithNumber, CompanyCardFeedWithDomainID} from '@src/types/onyx/CardFeeds';
1111

1212
/**
1313
* Gets the Plaid Link token used to initialize the Plaid SDK
@@ -147,8 +147,6 @@ function importPlaidAccounts(
147147
country: string,
148148
domainName: string,
149149
plaidAccounts: string,
150-
statementPeriodEnd: StatementPeriodEnd | undefined,
151-
statementPeriodEndDay: StatementPeriodEndDay | undefined,
152150
plaidAccessToken: string | undefined,
153151
) {
154152
const parameters: ImportPlaidAccountsParams = {
@@ -158,8 +156,6 @@ function importPlaidAccounts(
158156
country,
159157
domainName,
160158
plaidAccounts,
161-
statementPeriodEnd,
162-
statementPeriodEndDay,
163159
plaidAccessToken,
164160
};
165161

src/pages/workspace/companyCards/BankConnection/index.native.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,9 @@ function BankConnection({policyID: policyIDFromProps, feed, route, title}: BankC
143143
updateSelectedFeed(newFeed, policyID);
144144
}
145145

146-
// Direct feeds (except those added via Plaid) are created with default statement period end date.
147-
// Redirect the user to set a custom date.
148-
if (policyID && !isPlaid) {
149-
setAddNewCompanyCardStepAndData({
150-
step: CONST.COMPANY_CARDS.STEP.SELECT_DIRECT_STATEMENT_CLOSE_DATE,
151-
});
152-
} else {
153-
Navigation.goBack(ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(policyID));
154-
}
146+
Navigation.closeRHPFlow();
147+
Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(policyID), {forceReplace: true});
148+
return;
155149
}
156150
if (isPlaid) {
157151
onImportPlaidAccounts();

0 commit comments

Comments
 (0)