Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/libs/actions/Card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ function syncCard(cardID: number, lastScrapeResult?: number, breakConnection?: b
};

if (breakConnection) {
// Simulate "Account not found" error code for testing
parameters.breakConnection = 434;
// Simulate "Account refresh required" error code for testing
parameters.breakConnection = 438;
}

API.write(WRITE_COMMANDS.SYNC_CARD, parameters, {optimisticData, finallyData, failureData});
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/CompanyCards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,8 @@ function updateWorkspaceCompanyCard(domainOrWorkspaceAccountID: number, cardID:
};

if (breakConnection) {
// Simulate "Account not found" error code for testing
parameters.breakConnection = 434;
// Simulate "Account refresh required" error code for testing
parameters.breakConnection = 438;
}

API.write(WRITE_COMMANDS.SYNC_CARD, parameters, {optimisticData, finallyData, failureData});
Expand Down
9 changes: 5 additions & 4 deletions src/pages/settings/Wallet/PersonalCardDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
import useThemeIllustrations from '@hooks/useThemeIllustrations';
import useThemeStyles from '@hooks/useThemeStyles';
import {isUsingStagingApi} from '@libs/ApiUtils';
import {getCardFeedIcon, isCardConnectionBroken, isPersonalCard} from '@libs/CardUtils';
import {getLatestErrorField} from '@libs/ErrorUtils';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
Expand All @@ -40,7 +41,7 @@ type PersonalCardDetailsPageProps = PlatformStackScreenProps<SettingsNavigatorPa
function PersonalCardDetailsPage({route}: PersonalCardDetailsPageProps) {
const {cardID} = route.params;
const [customCardNames] = useOnyx(ONYXKEYS.NVP_EXPENSIFY_COMPANY_CARDS_CUSTOM_NAMES);
const [shouldUseStagingServer] = useOnyx(ONYXKEYS.SHOULD_USE_STAGING_SERVER);
const [shouldUseStagingServer = isUsingStagingApi()] = useOnyx(ONYXKEYS.SHOULD_USE_STAGING_SERVER);
const [isUnassignModalVisible, setIsUnassignModalVisible] = useState(false);
const {translate, getLocalDateFromDatetime} = useLocalize();
const styles = useThemeStyles();
Expand Down Expand Up @@ -86,10 +87,10 @@ function PersonalCardDetailsPage({route}: PersonalCardDetailsPageProps) {
syncCard(card.cardID, card.lastScrapeResult, true);
};

// Show "Break connection" option only for Mock Bank cards when the backend API is non-production
// Show "Break connection" only when Mock Bank requests target non-production APIs.
const isMockBank = cardBank.includes(CONST.COMPANY_CARDS.BANK_CONNECTIONS.MOCK_BANK);
const isNonProductionBackend = CONFIG.EXPENSIFY.EXPENSIFY_URL.includes('.dev') || CONFIG.EXPENSIFY.EXPENSIFY_URL.includes('staging') || !!shouldUseStagingServer;
const shouldShowBreakConnection = isMockBank && isNonProductionBackend;
const isUsingNonProductionAPI = shouldUseStagingServer || CONFIG.IS_USING_LOCAL_WEB;
const shouldShowBreakConnection = isMockBank && isUsingNonProductionAPI;

const lastScrape = card?.lastScrape
? format(getLocalDateFromDatetime(card.lastScrape), CONST.DATE.FNS_DATE_TIME_FORMAT_STRING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import usePolicy from '@hooks/usePolicy';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeIllustrations from '@hooks/useThemeIllustrations';
import useThemeStyles from '@hooks/useThemeStyles';
import {isUsingStagingApi} from '@libs/ApiUtils';
import {getCardFeedIcon, getCompanyCardFeed, getCompanyFeeds, getDefaultCardName, getDomainOrWorkspaceAccountID, getPlaidInstitutionIconUrl, maskCardNumber} from '@libs/CardUtils';
import {getLatestErrorField} from '@libs/ErrorUtils';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
Expand Down Expand Up @@ -53,7 +54,7 @@ function WorkspaceCompanyCardDetailsPage({route}: WorkspaceCompanyCardDetailsPag
const bank = getCompanyCardFeed(feedName);
const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`);
const [customCardNames] = useOnyx(ONYXKEYS.NVP_EXPENSIFY_COMPANY_CARDS_CUSTOM_NAMES);
const [shouldUseStagingServer] = useOnyx(ONYXKEYS.SHOULD_USE_STAGING_SERVER);
const [shouldUseStagingServer = isUsingStagingApi()] = useOnyx(ONYXKEYS.SHOULD_USE_STAGING_SERVER);
const policy = usePolicy(policyID);
const workspaceAccountID = policy?.workspaceAccountID ?? CONST.DEFAULT_NUMBER_ID;
const [isUnassignModalVisible, setIsUnassignModalVisible] = useState(false);
Expand Down Expand Up @@ -109,10 +110,10 @@ function WorkspaceCompanyCardDetailsPage({route}: WorkspaceCompanyCardDetailsPag
updateWorkspaceCompanyCard(domainOrWorkspaceAccountID, cardID, bank, card?.lastScrapeResult, true);
};

// Show "Break connection" option only for Mock Bank cards when the backend API is non-production
// Show "Break connection" only when Mock Bank requests target non-production APIs.
const isMockBank = bank?.includes(CONST.COMPANY_CARDS.BANK_CONNECTIONS.MOCK_BANK);
const isNonProductionBackend = CONFIG.EXPENSIFY.EXPENSIFY_URL.includes('.dev') || CONFIG.EXPENSIFY.EXPENSIFY_URL.includes('staging') || !!shouldUseStagingServer;
const shouldShowBreakConnection = isMockBank && isNonProductionBackend;
const isUsingNonProductionAPI = shouldUseStagingServer || CONFIG.IS_USING_LOCAL_WEB;
const shouldShowBreakConnection = isMockBank && isUsingNonProductionAPI;

const lastScrape = useMemo(() => {
if (!card?.lastScrape) {
Expand Down
Loading