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
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 11 additions & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ const CONST = {
EUR: 'EUR',
},
get DIRECT_REIMBURSEMENT_CURRENCIES() {
return [this.CURRENCY.USD, this.CURRENCY.AUD, this.CURRENCY.CAD, this.CURRENCY.GBP, this.CURRENCY.NZD, this.CURRENCY.EUR];
return [this.CURRENCY.USD, this.CURRENCY.AUD, this.CURRENCY.CAD, this.CURRENCY.GBP, this.CURRENCY.EUR];
},
EXAMPLE_PHONE_NUMBER: '+15005550006',
CONCIERGE_CHAT_NAME: 'Concierge',
Expand Down Expand Up @@ -1501,6 +1501,16 @@ const CONST = {
DISABLE: 'disable',
ENABLE: 'enable',
},
COLLECTION_KEYS: {
DESCRIPTION: 'description',
REIMBURSER_EMAIL: 'reimburserEmail',
REIMBURSEMENT_CHOICE: 'reimbursementChoice',
APPROVAL_MODE: 'approvalMode',
AUTOREPORTING: 'autoReporting',
AUTOREPORTING_FREQUENCY: 'autoReportingFrequency',
AUTOREPORTING_OFFSET: 'autoReportingOffset',
GENERAL_SETTINGS: 'generalSettings',
},
},

CUSTOM_UNITS: {
Expand Down
8 changes: 8 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,14 @@ export default {
},
},
},
workflowsDelayedSubmissionPage: {
autoReportingErrorMessage: 'The delayed submission parameter could not be changed. Please try again or contact support.',
autoReportingFrequencyErrorMessage: 'The submission frequency could not be changed. Please try again or contact support.',
monthlyOffsetErrorMessage: 'The monthly frequency could not be changed. Please try again or contact support.',
},
workflowsApprovalPage: {
genericErrorMessage: 'The approver could not be changed. Please try again or contact support.',
Comment on lines +1075 to +1080
Copy link
Contributor

Choose a reason for hiding this comment

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

Has marketing reviewed these copies?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Asked about it here

Copy link
Contributor

Choose a reason for hiding this comment

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

@lakchote This is usually done using Marketing label autoassigner on the linked issue so we get one dedicated person for this

},
workflowsPayerPage: {
title: 'Authorized payer',
genericErrorMessage: 'The authorized payer could not be changed. Please try again.',
Expand Down
8 changes: 8 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,14 @@ export default {
},
},
},
workflowsDelayedSubmissionPage: {
autoReportingErrorMessage: 'El parámetro de envío retrasado no pudo ser cambiado. Por favor, inténtelo de nuevo o contacte al soporte.',
autoReportingFrequencyErrorMessage: 'La frecuencia de envío no pudo ser cambiada. Por favor, inténtelo de nuevo o contacte al soporte.',
monthlyOffsetErrorMessage: 'La frecuencia mensual no pudo ser cambiada. Por favor, inténtelo de nuevo o contacte al soporte.',
},
workflowsApprovalPage: {
genericErrorMessage: 'El aprobador no pudo ser cambiado. Por favor, inténtelo de nuevo o contacte al soporte.',
},
workflowsPayerPage: {
title: 'Pagador autorizado',
genericErrorMessage: 'El pagador autorizado no se pudo cambiar. Por favor, inténtalo mas tarde.',
Expand Down
20 changes: 17 additions & 3 deletions src/libs/actions/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ function updateLastAccessedWorkspace(policyID: OnyxEntry<string>) {
Onyx.set(ONYXKEYS.LAST_ACCESSED_WORKSPACE_POLICY_ID, policyID);
}

/**
* Checks if the currency is supported for direct reimbursement
* USD currency is the only one supported in NewDot for now
*/
function isCurrencySupportedForDirectReimbursement(currency: string) {
return currency === CONST.CURRENCY.USD;
}

/**
* Check if the user has any active free policies (aka workspaces)
*/
Expand Down Expand Up @@ -471,6 +479,7 @@ function setWorkspaceAutoReporting(policyID: string, enabled: boolean, frequency
},
autoReportingFrequency: policy.autoReportingFrequency ?? null,
pendingFields: {autoReporting: null},
errorFields: {autoReporting: ErrorUtils.getMicroSecondOnyxError('workflowsDelayedSubmissionPage.autoReportingErrorMessage')},
},
},
];
Expand Down Expand Up @@ -511,6 +520,7 @@ function setWorkspaceAutoReportingFrequency(policyID: string, frequency: ValueOf
value: {
autoReportingFrequency: policy.autoReportingFrequency ?? null,
pendingFields: {autoReportingFrequency: null},
errorFields: {autoReportingFrequency: ErrorUtils.getMicroSecondOnyxError('workflowsDelayedSubmissionPage.autoReportingFrequencyErrorMessage')},
},
},
];
Expand Down Expand Up @@ -551,6 +561,7 @@ function setWorkspaceAutoReportingMonthlyOffset(policyID: string, autoReportingO
value: {
autoReportingOffset: policy.autoReportingOffset ?? null,
pendingFields: {autoReportingOffset: null},
errorFields: {autoReportingOffset: ErrorUtils.getMicroSecondOnyxError('workflowsDelayedSubmissionPage.monthlyOffsetErrorMessage')},
},
},
];
Expand Down Expand Up @@ -596,6 +607,7 @@ function setWorkspaceApprovalMode(policyID: string, approver: string, approvalMo
approver: policy.approver ?? null,
approvalMode: policy.approvalMode ?? null,
pendingFields: {approvalMode: null},
errorFields: {approvalMode: ErrorUtils.getMicroSecondOnyxError('workflowsApprovalPage.genericErrorMessage')},
},
},
];
Expand Down Expand Up @@ -666,8 +678,8 @@ function setWorkspacePayer(policyID: string, reimburserEmail: string, reimburser
API.write(WRITE_COMMANDS.SET_WORKSPACE_PAYER, params, {optimisticData, failureData, successData});
}

function clearWorkspacePayerError(policyID: string) {
Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {errorFields: {reimburserEmail: null}});
function clearPolicyErrorField(policyID: string, fieldName: string) {
Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {errorFields: {[fieldName]: null}});
}

function setWorkspaceReimbursement(policyID: string, reimbursementChoice: ValueOf<typeof CONST.POLICY.REIMBURSEMENT_CHOICES>, reimburserAccountID: number, reimburserEmail: string) {
Expand Down Expand Up @@ -1367,6 +1379,7 @@ function updateGeneralSettings(policyID: string, name: string, currency: string)
},
},
];

const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down Expand Up @@ -4305,7 +4318,6 @@ export {
renamePolicyCategory,
clearCategoryErrors,
setWorkspacePayer,
clearWorkspacePayerError,
setWorkspaceReimbursement,
openPolicyWorkflowsPage,
setPolicyRequiresTag,
Expand Down Expand Up @@ -4334,5 +4346,7 @@ export {
setWorkspaceCurrencyDefault,
setForeignCurrencyDefault,
setPolicyCustomTaxName,
clearPolicyErrorField,
isCurrencySupportedForDirectReimbursement,
clearPolicyDistanceRatesErrorFields,
};
14 changes: 12 additions & 2 deletions src/pages/workspace/WorkspaceProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import useLocalize from '@hooks/useLocalize';
import useThemeIllustrations from '@hooks/useThemeIllustrations';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import * as ErrorUtils from '@libs/ErrorUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportUtils from '@libs/ReportUtils';
Expand Down Expand Up @@ -173,7 +174,11 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi
/>
</OfflineWithFeedback>
{(!StringUtils.isEmptyString(policy?.description ?? '') || !readOnly) && (
<OfflineWithFeedback pendingAction={policy?.pendingFields?.description}>
<OfflineWithFeedback
pendingAction={policy?.pendingFields?.description}
errors={ErrorUtils.getLatestErrorField(policy ?? {}, CONST.POLICY.COLLECTION_KEYS.DESCRIPTION)}
onClose={() => Policy.clearPolicyErrorField(policy?.id ?? '', CONST.POLICY.COLLECTION_KEYS.DESCRIPTION)}
>
<MenuItemWithTopDescription
title={policyDescription}
description={translate('workspace.editor.descriptionInputLabel')}
Expand All @@ -187,7 +192,12 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi
/>
</OfflineWithFeedback>
)}
<OfflineWithFeedback pendingAction={policy?.pendingFields?.generalSettings}>
<OfflineWithFeedback
pendingAction={policy?.pendingFields?.generalSettings}
errors={ErrorUtils.getLatestErrorField(policy ?? {}, CONST.POLICY.COLLECTION_KEYS.GENERAL_SETTINGS)}
onClose={() => Policy.clearPolicyErrorField(policy?.id ?? '', CONST.POLICY.COLLECTION_KEYS.GENERAL_SETTINGS)}
errorRowStyles={[styles.mt2]}
>
<View>
<MenuItemWithTopDescription
title={formattedCurrency}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ScreenWrapper from '@components/ScreenWrapper';
import RadioListItem from '@components/SelectionList/RadioListItem';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as ErrorUtils from '@libs/ErrorUtils';
import * as Localize from '@libs/Localize';
import Navigation from '@libs/Navigation/Navigation';
import type {WorkspacesCentralPaneNavigatorParamList} from '@libs/Navigation/types';
Expand Down Expand Up @@ -84,7 +85,12 @@ function WorkspaceAutoReportingFrequencyPage({policy, route}: WorkspaceAutoRepor
};

const monthlyFrequencyDetails = () => (
<OfflineWithFeedback pendingAction={policy?.pendingFields?.autoReportingOffset}>
<OfflineWithFeedback
pendingAction={policy?.pendingFields?.autoReportingOffset}
errors={ErrorUtils.getLatestErrorField(policy ?? {}, CONST.POLICY.COLLECTION_KEYS.AUTOREPORTING_OFFSET)}
onClose={() => Policy.clearPolicyErrorField(policy?.id ?? '', CONST.POLICY.COLLECTION_KEYS.AUTOREPORTING_OFFSET)}
errorRowStyles={[styles.ml7]}
>
<MenuItem
title={translate('workflowsPage.submissionFrequencyDateOfMonth')}
titleStyle={styles.textLabelSupportingNormal}
Expand Down Expand Up @@ -127,12 +133,17 @@ function WorkspaceAutoReportingFrequencyPage({policy, route}: WorkspaceAutoRepor
title={translate('workflowsPage.submissionFrequency')}
onBackButtonPress={Navigation.goBack}
/>

<FlatList
data={autoReportingFrequencyItems}
renderItem={renderItem}
keyExtractor={(item: WorkspaceAutoReportingFrequencyPageItem) => item.text}
/>
<OfflineWithFeedback
pendingAction={policy?.pendingFields?.autoReportingFrequency}
errors={ErrorUtils.getLatestErrorField(policy ?? {}, CONST.POLICY.COLLECTION_KEYS.AUTOREPORTING_FREQUENCY)}
onClose={() => Policy.clearPolicyErrorField(policy?.id ?? '', CONST.POLICY.COLLECTION_KEYS.AUTOREPORTING_FREQUENCY)}
>
<FlatList
data={autoReportingFrequencyItems}
renderItem={renderItem}
keyExtractor={(item: WorkspaceAutoReportingFrequencyPageItem) => item.text}
/>
</OfflineWithFeedback>
</FullPageNotFoundView>
</ScreenWrapper>
</FeatureEnabledAccessOrNotFoundWrapper>
Expand Down
Loading
Loading