Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wave Collect] [Workflows] Display meaningful message when currency is not available for Direct Reimbursement #38318

Merged
merged 36 commits into from
Mar 20, 2024
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
16cae1b
handle errors
lakchote Mar 14, 2024
cff3658
add translations for workflows errors
lakchote Mar 14, 2024
47c3c74
handle workflows errors
lakchote Mar 14, 2024
e515c8e
add errors for failure data
lakchote Mar 14, 2024
a280421
create method to check valid currency for reimbursement
lakchote Mar 14, 2024
ef1d156
handle errors for workspace name and description
lakchote Mar 14, 2024
3aa3925
make method more specific
lakchote Mar 18, 2024
a7d48f2
show currency modal switcher if vbba not set and fix default reimburs…
lakchote Mar 18, 2024
b3d9939
fix style
lakchote Mar 18, 2024
20af98e
remove unneeded translation key
lakchote Mar 18, 2024
be8fd34
remove old logic for edge case when default reimbursement choice was …
lakchote Mar 18, 2024
e053abc
Merge branch 'main' into lucien/fix-worklows-error-messages
lakchote Mar 18, 2024
c1c65f6
fix typo
lakchote Mar 18, 2024
f385e85
add consts for policy collection fields
lakchote Mar 19, 2024
7cc1c1a
add generic method to clear policy error fields
lakchote Mar 19, 2024
9f0a1fe
use const for policy collection fields
lakchote Mar 19, 2024
7343b48
remove currency not available as direct reimbursement
lakchote Mar 19, 2024
b7b2a07
improved logic for hasValidCurrencyForDirectReimbursement()
lakchote Mar 19, 2024
84a1c83
improved naming
lakchote Mar 19, 2024
7c95b21
Merge branch 'main' into lucien/fix-worklows-error-messages
lakchote Mar 19, 2024
a2a788e
rename method and filter EUR currency for direct reimbursement as it'…
lakchote Mar 19, 2024
428bbe6
fix reimbursement choice
lakchote Mar 19, 2024
39f9161
fix lint
lakchote Mar 19, 2024
cf6a4bd
fix style
lakchote Mar 19, 2024
c2a82ca
fix edge case
lakchote Mar 19, 2024
14a7018
Merge branch 'main' into lucien/fix-worklows-error-messages
lakchote Mar 19, 2024
801c6ae
fix currency supported
lakchote Mar 20, 2024
086c310
Merge branch 'main' into lucien/fix-worklows-error-messages
lakchote Mar 20, 2024
fc71b6d
improved naming
lakchote Mar 20, 2024
45c7923
use new naming for const collection keys
lakchote Mar 20, 2024
c1d1aa6
fix toggle logic
lakchote Mar 20, 2024
172c8b3
improved toggle logic
lakchote Mar 20, 2024
1140772
Merge branch 'main' into lucien/fix-worklows-error-messages
lakchote Mar 20, 2024
a932d16
fix style
lakchote Mar 20, 2024
256049f
Merge branch 'main' into lucien/fix-worklows-error-messages
lakchote Mar 20, 2024
adb5d5e
fix toggle logic
lakchote Mar 20, 2024
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
18 changes: 11 additions & 7 deletions src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ function WorkspaceWorkflowsPage({policy, betas, route, reimbursementAccount, ses
title: translate('workflowsPage.makeOrTrackPaymentsTitle'),
subtitle: translate('workflowsPage.makeOrTrackPaymentsDescription'),
onToggle: () => {
const isActive = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES;

const newReimbursementChoice = isActive ? CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL : CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES;

const shouldUseDirectReimbursement = !isActive && Policy.isCurrencySupportedForDirectReimbursement(policy?.outputCurrency ?? '');
const shouldUseDirectReimbursement =
policy?.reimbursementChoice !== CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES &&
Policy.isCurrencySupportedForDirectReimbursement(policy?.outputCurrency ?? '');

// If trying to enable direct reimbursement and currency is not supported, default to manual (indirect) reimbursement
const effectiveReimbursementChoice = shouldUseDirectReimbursement ? newReimbursementChoice : CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL;
const effectiveReimbursementChoice = shouldUseDirectReimbursement
? CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES
: CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL;
Copy link
Contributor

Choose a reason for hiding this comment

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

Almost there! If I revert the change I commented on here, I can't toggle off, because we now never set REIMBURSEMENT_NO. The way I see it, we need to check if we are enabling the toggle (reimbursementChoice === REIMBURSEMENT_NO), then switch between REIMBURSEMENT_YES and REIMBURSEMENT_MANUAL based on shouldUseDirectReimbursement, otherwise we are turning the toggle off so should set to REIMBURSEMENT_NO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @jjcoffee, I've pushed up a new commit here, let me know what you think!


const newReimburserAccountID =
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
Expand All @@ -181,7 +181,11 @@ function WorkspaceWorkflowsPage({policy, betas, route, reimbursementAccount, ses
<MenuItem
titleStyle={styles.textLabelSupportingNormal}
descriptionTextStyle={styles.textNormalThemeText}
title={hasVBA && policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES ? translate('common.bankAccount') : translate('workflowsPage.connectBankAccount')}
title={
hasVBA && policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES
? translate('common.bankAccount')
: translate('workflowsPage.connectBankAccount')
}
description={state === BankAccount.STATE.OPEN ? bankDisplayName : undefined}
onPress={() => {
if (!Policy.isCurrencySupportedForDirectReimbursement(policy?.outputCurrency ?? '')) {
Expand Down
Loading