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
15 changes: 15 additions & 0 deletions src/hooks/useCanEnrollNewExpensifyCardProgram.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import CONST from '@src/CONST';

import useExpensifyCardUkEuSupported from './useExpensifyCardUkEuSupported';
import usePolicy from './usePolicy';

/**
* Whether the workspace currency allows enrollment in a new Expensify Card program.
* Linking an existing card feed is not restricted by currency.
*/
export default function useCanEnrollNewExpensifyCardProgram(policyID?: string) {
const policy = usePolicy(policyID);
const isUkEuCurrencySupported = useExpensifyCardUkEuSupported(policyID);

return policy?.outputCurrency === CONST.CURRENCY.USD || isUkEuCurrencySupported;
}
3 changes: 3 additions & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7216,6 +7216,9 @@ Der Control-Tarif beginnt bei 9 $ pro aktivem Mitglied und Monat.`,
yourWorkspace: `Dein Arbeitsbereich ist auf eine nicht unterstützte Währung eingestellt. Sieh dir die <a href="${CONST.ENABLE_GLOBAL_REIMBURSEMENT_HELP_URL}">Liste der unterstützten Währungen</a> an.`,
chooseAnExisting: 'Wähle ein bestehendes Bankkonto zum Bezahlen von Ausgaben oder füge ein neues hinzu.',
changeBankAccount: 'Bankkonto ändern',
updateCurrencyForExpensifyCard:
'Die Expensify Karte funktioniert mit Bankkonten in USD, GBP und EUR. Aktualisieren Sie diesen Workspace auf eine unterstützte Währung oder verwenden Sie einen anderen Workspace für die Registrierung.',
updateCurrencyForExpensifyCardTitle: 'Holen Sie sich die Expensify Karte',
},
changeOwner: {
changeOwnerPageTitle: 'Besitz übertragen',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/el.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7477,6 +7477,9 @@ _Για πιο αναλυτικές οδηγίες, [επισκεφθείτε τ
notAllowedToAddBankAccount:
'Ο χώρος εργασίας σας είναι ρυθμισμένος σε μη υποστηριζόμενο νόμισμα. Επικοινωνήστε με έναν διαχειριστή χώρου εργασίας που έχει δικαίωμα να το αλλάξει.',
changeBankAccount: 'Αλλαγή τραπεζικού λογαριασμού',
updateCurrencyForExpensifyCard:
'Η κάρτα Expensify λειτουργεί με τραπεζικούς λογαριασμούς σε USD, GBP και EUR. Ενημερώστε αυτόν τον χώρο εργασίας σε υποστηριζόμενο νόμισμα ή χρησιμοποιήστε έναν διαφορετικό χώρο εργασίας για να εγγραφείτε.',
updateCurrencyForExpensifyCardTitle: 'Αποκτήστε την κάρτα Expensify',
},
changeOwner: {
changeOwnerPageTitle: 'Μεταφορά ιδιοκτήτη',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7406,6 +7406,9 @@ const translations = {
areYouSure: 'Are you sure?',
workspaceCurrency: 'Workspace currency',
updateCurrencyPrompt: 'It looks like your workspace is currently set to a different currency than USD. Please click the button below to update your currency to USD now.',
updateCurrencyForExpensifyCard:
'The Expensify Card is available to issue in USD, GBP, and EUR. Please update this workspace to a supported currency or use a different workspace.',
updateCurrencyForExpensifyCardTitle: 'Get the Expensify Card',
updateToUSD: 'Update to USD',
updateWorkspaceCurrency: 'Update workspace currency',
workspaceCurrencyNotSupported: 'Workspace currency not supported',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7181,6 +7181,9 @@ El plan Controlar empieza en 9 $ por miembro activo al mes.`,
yourWorkspace: `Tu espacio de trabajo está configurado en una moneda no soportada. Consulta la <a href="${CONST.ENABLE_GLOBAL_REIMBURSEMENT_HELP_URL}">lista de monedas soportadas</a>.`,
chooseAnExisting: 'Elige una cuenta bancaria existente para pagar gastos o añade una nueva.',
changeBankAccount: 'Cambiar cuenta bancaria',
updateCurrencyForExpensifyCard:
'La Tarjeta Expensify funciona con cuentas bancarias en USD, GBP y EUR. Actualiza este espacio de trabajo a una divisa compatible o usa otro espacio de trabajo para inscribirte.',
updateCurrencyForExpensifyCardTitle: 'Consigue la Tarjeta Expensify',
},
changeOwner: {
changeOwnerPageTitle: 'Transferir la propiedad',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7242,6 +7242,9 @@ Le forfait Control commence à 9 $ par Membre actif et par mois.`,
yourWorkspace: `Votre espace de travail est défini sur une devise non prise en charge. Consultez la <a href="${CONST.ENABLE_GLOBAL_REIMBURSEMENT_HELP_URL}">liste des devises prises en charge</a>.`,
chooseAnExisting: 'Choisissez un compte bancaire existant pour payer les dépenses ou ajoutez-en un nouveau.',
changeBankAccount: 'Changer de compte bancaire',
updateCurrencyForExpensifyCard:
'La Carte Expensify fonctionne avec des comptes bancaires en USD, GBP et EUR. Mettez à jour cet espace de travail vers une devise prise en charge ou utilisez un autre espace de travail pour vous inscrire.',
updateCurrencyForExpensifyCardTitle: 'Obtenez la Carte Expensify',
},
changeOwner: {
changeOwnerPageTitle: 'Transférer le responsable',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7184,6 +7184,9 @@ Il piano Control parte da 9 $ al mese per ogni membro attivo.`,
yourWorkspace: `La tua area di lavoro è impostata su una valuta non supportata. Visualizza l’<a href="${CONST.ENABLE_GLOBAL_REIMBURSEMENT_HELP_URL}">elenco delle valute supportate</a>.`,
chooseAnExisting: 'Scegli un conto bancario esistente per pagare le spese oppure aggiungine uno nuovo.',
changeBankAccount: 'Cambia conto bancario',
updateCurrencyForExpensifyCard:
'La Carta Expensify funziona con conti bancari in USD, GBP ed EUR. Aggiorna questo spazio di lavoro a una valuta supportata oppure usa un altro spazio di lavoro per iscriverti.',
updateCurrencyForExpensifyCardTitle: 'Ottieni la Carta Expensify',
},
changeOwner: {
changeOwnerPageTitle: 'Trasferisci proprietario',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7101,6 +7101,9 @@ Control プランは、アクティブメンバー1人あたり月額 $9 から
yourWorkspace: `ご利用のワークスペースはサポートされていない通貨に設定されています。<a href="${CONST.ENABLE_GLOBAL_REIMBURSEMENT_HELP_URL}">サポートされている通貨の一覧</a>を表示します。`,
chooseAnExisting: '既存の銀行口座を選択して経費を支払うか、新しい口座を追加してください。',
changeBankAccount: '銀行口座を変更',
updateCurrencyForExpensifyCard:
'Expensify カードは、USD・GBP・EUR の銀行口座でご利用いただけます。このワークスペースを対応通貨に更新するか、別のワークスペースで登録してください。',
updateCurrencyForExpensifyCardTitle: 'Expensify カードを取得する',
},
changeOwner: {
changeOwnerPageTitle: '所有者を変更',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7171,6 +7171,9 @@ Het Control-abonnement begint bij $9 per actieve deelnemer per maand.`,
yourWorkspace: `Je werkruimte is ingesteld op een niet-ondersteunde valuta. Bekijk de <a href="${CONST.ENABLE_GLOBAL_REIMBURSEMENT_HELP_URL}">lijst met ondersteunde valuta's</a>.`,
chooseAnExisting: 'Kies een bestaande bankrekening om onkosten te betalen of voeg een nieuwe toe.',
changeBankAccount: 'Bankrekening wijzigen',
updateCurrencyForExpensifyCard:
'Expensify Kaart werkt met bankrekeningen in USD, GBP en EUR. Werk deze workspace bij naar een ondersteunde valuta, of gebruik een andere workspace om je aan te melden.',
updateCurrencyForExpensifyCardTitle: 'Ontvang de Expensify Kaart',
},
changeOwner: {
changeOwnerPageTitle: 'Eigenaar overdragen',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7149,6 +7149,9 @@ Plan Control zaczyna się od 9 USD za aktywnego członka miesięcznie.`,
yourWorkspace: `Twoje miejsce pracy jest ustawione na nieobsługiwaną walutę. Zobacz <a href="${CONST.ENABLE_GLOBAL_REIMBURSEMENT_HELP_URL}">listę obsługiwanych walut</a>.`,
chooseAnExisting: 'Wybierz istniejące konto bankowe do opłacania wydatków lub dodaj nowe.',
changeBankAccount: 'Zmień konto bankowe',
updateCurrencyForExpensifyCard:
'Karta Expensify działa z kontami bankowymi w USD, GBP i EUR. Zmień walutę tego workspace’a na obsługiwaną albo użyj innego workspace’a, żeby się zarejestrować.',
updateCurrencyForExpensifyCardTitle: 'Zdobądź Kartę Expensify',
},
changeOwner: {
changeOwnerPageTitle: 'Przenieś właściciela',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7170,6 +7170,9 @@ O plano Control começa em US$ 9 por membro ativo por mês.`,
yourWorkspace: `Seu workspace está configurado para uma moeda não compatível. Veja a <a href="${CONST.ENABLE_GLOBAL_REIMBURSEMENT_HELP_URL}">lista de moedas compatíveis</a>.`,
chooseAnExisting: 'Escolha uma conta bancária existente para pagar despesas ou adicione uma nova.',
changeBankAccount: 'Alterar conta bancária',
updateCurrencyForExpensifyCard:
'O Cartão Expensify funciona com contas bancárias em USD, GBP e EUR. Atualize este workspace para uma moeda compatível ou use outro workspace para se inscrever.',
updateCurrencyForExpensifyCardTitle: 'Obtenha o Cartão Expensify',
},
changeOwner: {
changeOwnerPageTitle: 'Transferir proprietário',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6932,6 +6932,8 @@ _如需更详细的说明,请[访问我们的帮助网站](${CONST.NETSUITE_IM
yourWorkspace: `您的工作区当前使用不受支持的货币。请查看<a href="${CONST.ENABLE_GLOBAL_REIMBURSEMENT_HELP_URL}">支持的货币列表</a>。`,
chooseAnExisting: '选择现有银行账户来支付报销,或添加新账户。',
changeBankAccount: '更改银行账户',
updateCurrencyForExpensifyCard: 'Expensify 卡支持美元、英镑和欧元银行账户。请将此工作区更新为支持的货币,或使用其他工作区进行注册。',
updateCurrencyForExpensifyCardTitle: '获取 Expensify 卡',
},
changeOwner: {
changeOwnerPageTitle: '转移所有者',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SingleSelectListItem from '@components/SelectionList/ListItem/SingleSelec
import type {ListItem} from '@components/SelectionList/types';
import Text from '@components/Text';

import useCanEnrollNewExpensifyCardProgram from '@hooks/useCanEnrollNewExpensifyCardProgram';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useDefaultFundID from '@hooks/useDefaultFundID';
import useExpensifyCardFeedsForFeedSelector from '@hooks/useExpensifyCardFeedsForFeedSelector';
Expand Down Expand Up @@ -83,6 +84,7 @@ function WorkspaceExpensifyCardFeedSelectorPage({route}: WorkspaceExpensifyCardF
const [cardList] = useOnyx(ONYXKEYS.CARD_LIST);
const policy = usePolicy(policyID);
const canWriteExpensifyCard = canMemberWrite(policy, currentUserLogin, CONST.POLICY.POLICY_FEATURE.EXPENSIFY_CARD);
const canEnrollNewCardProgram = useCanEnrollNewExpensifyCardProgram(policyID);

const getIssueCardFundID = () => {
if (primaryFeeds.length === 0) {
Expand Down Expand Up @@ -200,14 +202,20 @@ function WorkspaceExpensifyCardFeedSelectorPage({route}: WorkspaceExpensifyCardF

const primaryListData = primaryFeeds.map((entry) => toListItem(entry, false));

// Suppress the new-program branch on workspaces with unsupported currencies
// These workspaces may only issue cards on existing feeds
const shouldShowIssueCardButton = issueCardFundID !== undefined || canEnrollNewCardProgram;

const issueNewCardAndOtherFeedsFooter = canWriteExpensifyCard ? (
<View style={[styles.w100, styles.flexColumn]}>
<MenuItemAction
title={translate(issueCardFundID !== undefined ? 'workspace.expensifyCard.issueCard' : 'workspace.expensifyCard.issueNewCard')}
icon={expensifyIcons.Plus}
onPress={issueCardFundID !== undefined ? handleAddCardPress : handleSetUpNewProgramPress}
sentryLabel={CONST.SENTRY_LABEL.WORKSPACE.EXPENSIFY_CARD.ISSUE_CARD_BUTTON}
/>
{shouldShowIssueCardButton && (
<MenuItemAction
title={translate(issueCardFundID !== undefined ? 'workspace.expensifyCard.issueCard' : 'workspace.expensifyCard.issueNewCard')}
icon={expensifyIcons.Plus}
onPress={issueCardFundID !== undefined ? handleAddCardPress : handleSetUpNewProgramPress}
sentryLabel={CONST.SENTRY_LABEL.WORKSPACE.EXPENSIFY_CARD.ISSUE_CARD_BUTTON}
/>
)}
{otherFeeds.length > 0 && (
<>
<Text style={[styles.ph5, styles.mv2, styles.textLabelSupporting]}>{translate('workspace.companyCards.fromOtherWorkspaces')}</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {useLockedAccountActions, useLockedAccountState} from '@components/Locked
import {ModalActions} from '@components/Modal/Global/ModalContext';
import Text from '@components/Text';

import useCanEnrollNewExpensifyCardProgram from '@hooks/useCanEnrollNewExpensifyCardProgram';
import useConfirmModal from '@hooks/useConfirmModal';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useExpensifyCardFeedsForFeedSelector from '@hooks/useExpensifyCardFeedsForFeedSelector';
Expand Down Expand Up @@ -34,8 +35,6 @@ import WorkspacePageWithSections from '@pages/workspace/WorkspacePageWithSection

import variables from '@styles/variables';

import {updateGeneralSettings as updatePolicyGeneralSettings} from '@userActions/Policy/Policy';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES';
Expand Down Expand Up @@ -78,6 +77,7 @@ function WorkspaceExpensifyCardPageEmptyState({route, policy}: WorkspaceExpensif

const isSetupUnfinished = hasInProgressUSDVBBA(reimbursementAccount?.achData);
const isUkEuCurrencySupported = useExpensifyCardUkEuSupported(policy?.id);
const canEnrollNewCardProgram = useCanEnrollNewExpensifyCardProgram(policy?.id);
const {allFeeds} = useExpensifyCardFeedsForFeedSelector(policy?.id);
const hasAccessibleFeeds = allFeeds.length > 0;

Expand Down Expand Up @@ -127,18 +127,17 @@ function WorkspaceExpensifyCardPageEmptyState({route, policy}: WorkspaceExpensif
const promptCurrencyChangeAndStartFlow = async () => {
isCurrencyModalOpen.current = true;
const result = await showConfirmModal({
title: translate('workspace.common.expensifyCard'),
prompt: translate('workspace.bankAccount.updateCurrencyPrompt'),
confirmText: translate('workspace.bankAccount.updateToUSD'),
title: translate('workspace.bankAccount.updateCurrencyForExpensifyCardTitle'),
prompt: translate('workspace.bankAccount.updateCurrencyForExpensifyCard'),
confirmText: translate('workspace.bankAccount.updateWorkspaceCurrency'),
cancelText: translate('common.cancel'),
danger: true,
});
isCurrencyModalOpen.current = false;
if (result.action !== ModalActions.CONFIRM || !policy) {
return;
}
updatePolicyGeneralSettings(policy, policy.name, CONST.CURRENCY.USD);
startFlow();
Navigation.navigate(ROUTES.WORKSPACE_OVERVIEW_CURRENCY.getRoute(policy.id, true));
};

return (
Expand Down Expand Up @@ -175,7 +174,9 @@ function WorkspaceExpensifyCardPageEmptyState({route, policy}: WorkspaceExpensif
showLockedAccountModal();
return;
}
if (!(policy?.outputCurrency === CONST.CURRENCY.USD || isUkEuCurrencySupported)) {
// The supported currency restriction only applies to enrolling a brand-new card program.
// If hasAccessibleFeeds is true, allow the flow to start in order to link an existing feed
if (!hasAccessibleFeeds && !canEnrollNewCardProgram) {
promptCurrencyChangeAndStartFlow();
return;
}
Expand Down
Loading