Skip to content

Commit

Permalink
Merge pull request Expensify#48779 from dominictb/fix/48749
Browse files Browse the repository at this point in the history
fix: policy id shows as domain card description
  • Loading branch information
MariaHCD authored Sep 12, 2024
2 parents 2830add + e52e9a9 commit cf07039
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const CURRENT_YEAR = new Date().getFullYear();
const PULL_REQUEST_NUMBER = Config?.PULL_REQUEST_NUMBER ?? '';
const MAX_DATE = dateAdd(new Date(), {years: 1});
const MIN_DATE = dateSubtract(new Date(), {years: 20});
const EXPENSIFY_POLICY_DOMAIN = 'expensify-policy';
const EXPENSIFY_POLICY_DOMAIN_EXTENSION = '.exfy';

const keyModifierControl = KeyCommand?.constants?.keyModifierControl ?? 'keyModifierControl';
const keyModifierCommand = KeyCommand?.constants?.keyModifierCommand ?? 'keyModifierCommand';
Expand Down Expand Up @@ -725,8 +727,8 @@ const CONST = {
INBOX: 'inbox',
},

EXPENSIFY_POLICY_DOMAIN: 'expensify-policy',
EXPENSIFY_POLICY_DOMAIN_EXTENSION: '.exfy',
EXPENSIFY_POLICY_DOMAIN,
EXPENSIFY_POLICY_DOMAIN_EXTENSION,

SIGN_IN_FORM_WIDTH: 300,

Expand Down Expand Up @@ -2590,6 +2592,10 @@ const CONST = {
SHORT_MENTION: new RegExp(`@[\\w\\-\\+\\'#@]+(?:\\.[\\w\\-\\'\\+]+)*(?![^\`]*\`)`, 'gim'),

REPORT_ID_FROM_PATH: /\/r\/(\d+)/,

get EXPENSIFY_POLICY_DOMAIN_NAME() {
return new RegExp(`${EXPENSIFY_POLICY_DOMAIN}([a-zA-Z0-9]+)\\${EXPENSIFY_POLICY_DOMAIN_EXTENSION}`);
},
},

PRONOUNS: {
Expand Down
15 changes: 13 additions & 2 deletions src/pages/settings/Wallet/PaymentMethodList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as CardUtils from '@libs/CardUtils';
import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
import * as PaymentUtils from '@libs/PaymentUtils';
import * as PolicyUtils from '@libs/PolicyUtils';
import variables from '@styles/variables';
import * as PaymentMethods from '@userActions/PaymentMethods';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -199,6 +200,16 @@ function PaymentMethodList({
const {isOffline} = useNetwork();
const [isUserValidated] = useOnyx(ONYXKEYS.USER, {selector: (user) => !!user?.validated});

const getDescriptionForPolicyDomainCard = (domainName: string): string => {
// A domain name containing a policyID indicates that this is a workspace feed
const policyID = domainName.match(CONST.REGEX.EXPENSIFY_POLICY_DOMAIN_NAME)?.[1];
if (policyID) {
const policy = PolicyUtils.getPolicy(policyID.toUpperCase());
return policy?.name ?? domainName;
}
return domainName;
};

const filteredPaymentMethods = useMemo(() => {
if (shouldShowAssignedCards) {
const assignedCards = Object.values(cardList ?? {})
Expand All @@ -214,7 +225,7 @@ function PaymentMethodList({
assignedCardsGrouped.push({
key: card.cardID.toString(),
title: card.bank,
description: card.domainName,
description: getDescriptionForPolicyDomainCard(card.domainName),
shouldShowRightIcon: false,
interactive: false,
canDismissError: false,
Expand Down Expand Up @@ -245,7 +256,7 @@ function PaymentMethodList({
key: card.cardID.toString(),
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
title: card?.nameValuePairs?.cardTitle || card.bank,
description: card.domainName,
description: getDescriptionForPolicyDomainCard(card.domainName),
onPress: () => Navigation.navigate(ROUTES.SETTINGS_WALLET_DOMAINCARD.getRoute(String(card.cardID))),
isGroupedCardDomain: !isAdminIssuedVirtualCard,
shouldShowRightIcon: true,
Expand Down

0 comments on commit cf07039

Please sign in to comment.