Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/hooks/useImportPlaidAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ export default function useImportPlaidAccounts(policyID?: string) {
if (!policyID || !plaidToken || !plaidFeed || !plaidFeedName || !country || !plaidAccounts?.length) {
return;
}
importPlaidAccounts(plaidToken, plaidFeed, plaidFeedName, country, getDomainNameForPolicy(policyID), JSON.stringify(plaidAccounts), statementPeriodEnd, statementPeriodEndDay);
importPlaidAccounts(plaidToken, plaidFeed, plaidFeedName, country, getDomainNameForPolicy(policyID), JSON.stringify(plaidAccounts), statementPeriodEnd, statementPeriodEndDay, '');
}, [statementPeriodEnd, statementPeriodEndDay, country, plaidAccounts, plaidFeed, plaidFeedName, plaidToken, policyID]);
}
1 change: 1 addition & 0 deletions src/libs/API/parameters/ImportPlaidAccountsParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type ImportPlaidAccountsParams = {
plaidAccounts: string;
statementPeriodEnd?: StatementPeriodEnd;
statementPeriodEndDay?: StatementPeriodEndDay;
plaidAccessToken?: string;
};

export default ImportPlaidAccountsParams;
2 changes: 2 additions & 0 deletions src/libs/actions/Plaid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ function importPlaidAccounts(
plaidAccounts: string,
statementPeriodEnd: StatementPeriodEnd | undefined,
statementPeriodEndDay: StatementPeriodEndDay | undefined,
plaidAccessToken: string | undefined,
) {
const parameters: ImportPlaidAccountsParams = {
publicToken,
Expand All @@ -136,6 +137,7 @@ function importPlaidAccounts(
plaidAccounts,
statementPeriodEnd,
statementPeriodEndDay,
plaidAccessToken,
};

API.write(WRITE_COMMANDS.IMPORT_PLAID_ACCOUNTS, parameters);
Expand Down
14 changes: 12 additions & 2 deletions src/pages/workspace/companyCards/WorkspaceCompanyCardsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import type {WorkspaceSplitNavigatorParamList} from '@libs/Navigation/types';
import {getPersonalDetailByEmail} from '@libs/PersonalDetailsUtils';
import {isDeletedPolicyEmployee} from '@libs/PolicyUtils';
import {getDomainNameForPolicy, isDeletedPolicyEmployee} from '@libs/PolicyUtils';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import WorkspacePageWithSections from '@pages/workspace/WorkspacePageWithSections';
import {clearAddNewCardFlow, openPolicyCompanyCardsFeed, openPolicyCompanyCardsPage, setAddNewCompanyCardStepAndData, setAssignCardStepAndData} from '@userActions/CompanyCards';
import {importPlaidAccounts} from '@userActions/Plaid';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
Expand Down Expand Up @@ -122,7 +123,16 @@ function WorkspaceCompanyCardsPage({route}: WorkspaceCompanyCardsPageProps) {

let currentStep: AssignCardStep = CONST.COMPANY_CARD.STEP.ASSIGNEE;
const employeeList = Object.values(policy?.employeeList ?? {}).filter((employee) => !isDeletedPolicyEmployee(employee, isOffline));
const isFeedExpired = isSelectedFeedExpired(selectedFeed ? cardFeeds?.settings?.oAuthAccountDetails?.[selectedFeed] : undefined);
const selectedFeedCompanyCardsData = selectedFeed ? cardFeeds?.settings?.companyCards?.[selectedFeed] : undefined;
const selectedFeedOAuthData = selectedFeed ? cardFeeds?.settings?.oAuthAccountDetails?.[selectedFeed] : undefined;
const isFeedExpired = isSelectedFeedExpired(selectedFeedOAuthData);
const plaidAccessToken = selectedFeedCompanyCardsData?.plaidAccessToken;

// Refetch plaid card list
if (!isFeedExpired && plaidAccessToken) {
const country = selectedFeedCompanyCardsData?.country ?? '';
importPlaidAccounts('', selectedFeed, '', country, getDomainNameForPolicy(policyID), '', undefined, undefined, plaidAccessToken);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ PERF-6 (docs)

In useEffect, useMemo, and useCallback, specify individual object properties as dependencies instead of passing entire objects.

The handleAssignCard function should specify individual properties as dependencies rather than using the entire objects:

const handleAssignCard = useCallback(() => {
    // ... existing logic
}, [
    isActingAsDelegate, 
    selectedFeed, 
    isOffline, 
    policy?.employeeList, 
    cardFeeds?.settings?.companyCards, 
    cardFeeds?.settings?.oAuthAccountDetails,
    policyID,
    filteredCardList,
    policy?.outputCurrency,
    countryByIp
]);

}

if (employeeList.length === 1) {
const userEmail = Object.keys(policy?.employeeList ?? {}).at(0) ?? '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ function PlaidConnectionStep({feed, policyID}: {feed?: CompanyCardFeed; policyID
JSON.stringify(metadata?.accounts),
addNewCard.data.statementPeriodEnd,
addNewCard.data.statementPeriodEndDay,
'',
);
// eslint-disable-next-line @typescript-eslint/no-deprecated
InteractionManager.runAfterInteractions(() => {
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/CardFeeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ type CustomCardFeedData = OnyxCommon.OnyxValueWithOfflineFeedback<{
/** Preferred policy */
preferredPolicy?: string;

/** Country associated with this feed (ISO 3166-1 alpha-2 code) */
country?: string;

/** The id of the domain the feed relates to */
domainID?: number;

Expand Down