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: 0 additions & 4 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ const ONYXKEYS = {
/** Keeps track if OpenApp failure modal is opened */
IS_OPEN_APP_FAILURE_MODAL_OPEN: 'isOpenAppFailureModalOpen',

/** Stores the PIN for an activated UK/EU Expensify card to be shown once after activation */
ACTIVATED_CARD_PIN: 'activatedCardPin',

/** Keeps track if there is a full screen currently visible or not */
FULLSCREEN_VISIBILITY: 'fullscreenVisibility',

Expand Down Expand Up @@ -1207,7 +1204,6 @@ type OnyxValuesMapping = {
[ONYXKEYS.RECENTLY_USED_CURRENCIES]: string[];
[ONYXKEYS.ACTIVE_CLIENTS]: string[];
[ONYXKEYS.DEVICE_ID]: string;
[ONYXKEYS.ACTIVATED_CARD_PIN]: string | undefined;
[ONYXKEYS.IS_SIDEBAR_LOADED]: boolean;
[ONYXKEYS.PERSISTED_REQUESTS]: OnyxTypes.Request[];
[ONYXKEYS.PERSISTED_ONGOING_REQUESTS]: OnyxTypes.Request;
Expand Down
4 changes: 2 additions & 2 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const WRITE_COMMANDS = {
BANK_ACCOUNT_HANDLE_PLAID_ERROR: 'BankAccount_HandlePlaidError',
REPORT_VIRTUAL_EXPENSIFY_CARD_FRAUD: 'ReportVirtualExpensifyCardFraud',
REQUEST_REPLACEMENT_EXPENSIFY_CARD: 'RequestReplacementExpensifyCard',
ACTIVATE_PHYSICAL_EXPENSIFY_CARD: 'ActivatePhysicalExpensifyCard',
RESOLVE_FRAUD_ALERT: 'ResolveFraudAlert',
UPDATE_EXPENSIFY_CARD_LIMIT: 'UpdateExpensifyCardLimit',
UPDATE_EXPENSIFY_CARD_TITLE: 'UpdateExpensifyCardTitle',
Expand Down Expand Up @@ -571,6 +572,7 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.BANK_ACCOUNT_HANDLE_PLAID_ERROR]: Parameters.BankAccountHandlePlaidErrorParams;
[WRITE_COMMANDS.REPORT_VIRTUAL_EXPENSIFY_CARD_FRAUD]: Parameters.ReportVirtualExpensifyCardFraudParams;
[WRITE_COMMANDS.REQUEST_REPLACEMENT_EXPENSIFY_CARD]: Parameters.RequestReplacementExpensifyCardParams;
[WRITE_COMMANDS.ACTIVATE_PHYSICAL_EXPENSIFY_CARD]: Parameters.ActivatePhysicalExpensifyCardParams;
[WRITE_COMMANDS.RESOLVE_FRAUD_ALERT]: Parameters.ResolveFraudAlertParams;
[WRITE_COMMANDS.UPDATE_EXPENSIFY_CARD_LIMIT]: Parameters.UpdateExpensifyCardLimitParams;
[WRITE_COMMANDS.UPDATE_EXPENSIFY_CARD_TITLE]: Parameters.UpdateExpensifyCardTitleParams;
Expand Down Expand Up @@ -1299,7 +1301,6 @@ const SIDE_EFFECT_REQUEST_COMMANDS = {
SET_PERSONAL_DETAILS_AND_REVEAL_EXPENSIFY_CARD: 'SetPersonalDetailsAndRevealExpensifyCard',
TWO_FACTOR_AUTH_VALIDATE: 'TwoFactorAuth_Validate',
CONNECT_AS_DELEGATE: 'ConnectAsDelegate',
ACTIVATE_PHYSICAL_EXPENSIFY_CARD: 'ActivatePhysicalExpensifyCard',
DISCONNECT_AS_DELEGATE: 'DisconnectAsDelegate',
COMPLETE_HYBRID_APP_ONBOARDING: 'CompleteHybridAppOnboarding',
CONNECT_POLICY_TO_QUICKBOOKS_DESKTOP: 'ConnectPolicyToQuickbooksDesktop',
Expand Down Expand Up @@ -1343,7 +1344,6 @@ type SideEffectRequestCommandParameters = {
[SIDE_EFFECT_REQUEST_COMMANDS.PAY_MONEY_REQUEST_ON_SEARCH]: Parameters.PayMoneyRequestOnSearchParams;
[SIDE_EFFECT_REQUEST_COMMANDS.MERGE_INTO_ACCOUNT_AND_LOGIN]: Parameters.MergeIntoAccountAndLogInParams;
[SIDE_EFFECT_REQUEST_COMMANDS.LOG_OUT]: Parameters.LogOutParams;
[SIDE_EFFECT_REQUEST_COMMANDS.ACTIVATE_PHYSICAL_EXPENSIFY_CARD]: Parameters.ActivatePhysicalExpensifyCardParams;
[SIDE_EFFECT_REQUEST_COMMANDS.CREATE_DIGITAL_WALLET]: Parameters.CreateDigitalWalletParams;
[SIDE_EFFECT_REQUEST_COMMANDS.VERIFY_TEST_DRIVE_RECIPIENT]: Parameters.VerifyTestDriveRecipientParams;
[SIDE_EFFECT_REQUEST_COMMANDS.LOCK_ACCOUNT]: Parameters.LockAccountParams;
Expand Down
18 changes: 1 addition & 17 deletions src/libs/actions/Card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,10 @@ function activatePhysicalExpensifyCard(cardLastFourDigits: string, cardID: numbe
cardID,
};

// eslint-disable-next-line rulesdir/no-api-side-effects-method
API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.ACTIVATE_PHYSICAL_EXPENSIFY_CARD, parameters, {
API.write(WRITE_COMMANDS.ACTIVATE_PHYSICAL_EXPENSIFY_CARD, parameters, {
optimisticData,
successData,
failureData,
}).then((response) => {
if (!response) {
return;
}
if (response.pin) {
Onyx.set(ONYXKEYS.ACTIVATED_CARD_PIN, response.pin);
}
});
}

Expand All @@ -236,13 +228,6 @@ function clearCardListErrors(cardID: number) {
Onyx.merge(ONYXKEYS.CARD_LIST, {[cardID]: {errors: null, isLoading: false}});
}

/**
* Clears the PIN for an activated card
*/
function clearActivatedCardPin() {
Onyx.set(ONYXKEYS.ACTIVATED_CARD_PIN, '');
}

function clearCardErrorField(cardID: number, fieldName: string) {
Onyx.merge(ONYXKEYS.CARD_LIST, {
[cardID]: {
Expand Down Expand Up @@ -1446,7 +1431,6 @@ export {
configureExpensifyCardsForPolicy,
issueExpensifyCard,
openCardDetailsPage,
clearActivatedCardPin,
clearCardErrorField,
clearCardNameValuePairsErrorField,
setPersonalCardReimbursable,
Expand Down
22 changes: 1 addition & 21 deletions src/pages/settings/Wallet/ExpensifyCardPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
import useThemeStyles from '@hooks/useThemeStyles';
import {resetValidateActionCodeSent} from '@libs/actions/User';
import {formatCardExpiration, getDomainCards, maskCard, maskPin} from '@libs/CardUtils';
import {formatCardExpiration, getDomainCards, maskCard} from '@libs/CardUtils';
import {convertToDisplayString, getCurrencyKeyByCountryCode} from '@libs/CurrencyUtils';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
Expand All @@ -34,7 +34,6 @@ import {buildCannedSearchQuery} from '@libs/SearchQueryUtils';
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
import RedDotCardSection from '@pages/settings/Wallet/RedDotCardSection';
import CardDetails from '@pages/settings/Wallet/WalletPage/CardDetails';
import {clearActivatedCardPin} from '@userActions/Card';
import {openOldDotLink} from '@userActions/Link';
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
Expand Down Expand Up @@ -83,7 +82,6 @@ function ExpensifyCardPage({route}: ExpensifyCardPageProps) {
const {cardID} = route.params;
const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: false});
const [cardList] = useOnyx(ONYXKEYS.CARD_LIST, {selector: filterOutPersonalCards, canBeMissing: false});
const [pin] = useOnyx(ONYXKEYS.ACTIVATED_CARD_PIN, {canBeMissing: true});
const [privatePersonalDetails] = useOnyx(ONYXKEYS.PRIVATE_PERSONAL_DETAILS, {canBeMissing: false});
const {currencyList} = useCurrencyList();
const styles = useThemeStyles();
Expand All @@ -107,15 +105,6 @@ function ExpensifyCardPage({route}: ExpensifyCardPageProps) {
}, [shouldDisplayCardDomain, cardList, cardID, domain]);
const currentCard = useMemo(() => cardsToShow?.find((card) => String(card?.cardID) === cardID) ?? cardsToShow?.at(0), [cardsToShow, cardID]);

useEffect(() => {
return () => {
if (!pin) {
return;
}
clearActivatedCardPin();
};
}, [pin]);

useEffect(() => {
setIsNotFound(!currentCard);
}, [cardList, cardsToShow, currentCard]);
Expand Down Expand Up @@ -149,7 +138,6 @@ function ExpensifyCardPage({route}: ExpensifyCardPageProps) {
const shouldShowReportLostCardButton = currentPhysicalCard?.state === CONST.EXPENSIFY_CARD.STATE.NOT_ACTIVATED || currentPhysicalCard?.state === CONST.EXPENSIFY_CARD.STATE.OPEN;

const currency = getCurrencyKeyByCountryCode(currencyList, currentCard?.nameValuePairs?.country ?? currentCard?.nameValuePairs?.feedCountry);
const shouldShowPIN = currency !== CONST.CURRENCY.USD;
const formattedAvailableSpendAmount = convertToDisplayString(currentCard?.availableSpend, currency);
const {limitNameKey, limitTitleKey} = getLimitTypeTranslationKeys(currentCard?.nameValuePairs?.limitType);

Expand Down Expand Up @@ -352,14 +340,6 @@ function ExpensifyCardPage({route}: ExpensifyCardPageProps) {
interactive={false}
titleStyle={styles.walletCardNumber}
/>
{shouldShowPIN && (
<MenuItemWithTopDescription
description={translate('cardPage.physicalCardPin')}
title={maskPin(pin)}
interactive={false}
titleStyle={styles.walletCardNumber}
/>
)}
<MenuItem
title={translate('reportCardLostOrDamaged.screenTitle')}
icon={expensifyIcons.Flag}
Expand Down
38 changes: 0 additions & 38 deletions tests/ui/WalletExpensifyCardPageTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,42 +202,4 @@ describe('ExpensifyCardPage', () => {
unmount();
await waitForBatchedUpdatesWithAct();
});

it('should show the PIN option on screen', async () => {
// Sign in as a test user before running the test.
await TestHelper.signInWithTestUser();

// Add a mock card to Onyx storage to simulate a valid card being loaded.
await act(async () => {
await Onyx.merge(ONYXKEYS.CARD_LIST, {
[userCardID]: {
cardID: 1234,
state: CONST.EXPENSIFY_CARD.STATE.OPEN,
domainName: 'xyz',
fundID: '12345',
nameValuePairs: {
isVirtual: false,
cardTitle: 'Test Card',
feedCountry: CONST.COUNTRY.GB,
},
availableSpend: 50000,
fraud: null,
},
});
});

// Render the page with the specified card ID.
const {unmount} = renderPage(SCREENS.SETTINGS.WALLET.DOMAIN_CARD, {cardID: '1234'});

await waitForBatchedUpdatesWithAct();

// Verify that the "PIN" option is displayed on the screen.
await waitFor(() => {
expect(screen.getByText(TestHelper.translateLocal('cardPage.physicalCardPin'))).toBeOnTheScreen();
});

// Unmount the component after assertions to clean up.
unmount();
await waitForBatchedUpdatesWithAct();
});
});
Loading