Skip to content

Commit 3938e13

Browse files
authored
Merge pull request Expensify#68812 from Expensify/marcaaron-rulesBackwardsCompat
2 parents 8faabff + 38b0f50 commit 3938e13

4 files changed

Lines changed: 16 additions & 8 deletions

File tree

src/CONST/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2895,9 +2895,14 @@ const CONST = {
28952895
USER: 'user',
28962896
},
28972897
AUTO_REIMBURSEMENT_MAX_LIMIT_CENTS: 2000000,
2898-
AUTO_REIMBURSEMENT_DEFAULT_LIMIT_CENTS: 10000,
2899-
AUTO_APPROVE_REPORTS_UNDER_DEFAULT_CENTS: 10000,
2900-
RANDOM_AUDIT_DEFAULT_PERCENTAGE: 0.05,
2898+
2899+
// Auto-reimbursement and auto-approval defaults are 0, but when enabled will use the suggested limit
2900+
AUTO_REIMBURSEMENT_LIMIT_DEFAULT_CENTS: 0,
2901+
AUTO_REIMBURSEMENT_LIMIT_SUGGESTED_CENTS: 10000,
2902+
AUTO_APPROVE_REPORTS_UNDER_DEFAULT_CENTS: 0,
2903+
AUTO_APPROVE_REPORTS_UNDER_SUGGESTED_CENTS: 10000,
2904+
RANDOM_AUDIT_DEFAULT_PERCENTAGE: 0.0,
2905+
RANDOM_AUDIT_SUGGESTED_PERCENTAGE: 0.05,
29012906

29022907
AUTO_REPORTING_FREQUENCIES: {
29032908
INSTANT: 'instant',

src/libs/actions/Policy/Policy.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5672,7 +5672,10 @@ function enableAutoApprovalOptions(policyID: string, enabled: boolean) {
56725672
return;
56735673
}
56745674

5675-
const autoApprovalValues = {auditRate: CONST.POLICY.RANDOM_AUDIT_DEFAULT_PERCENTAGE, limit: CONST.POLICY.AUTO_APPROVE_REPORTS_UNDER_DEFAULT_CENTS};
5675+
const autoApprovalValues = {
5676+
auditRate: enabled ? CONST.POLICY.RANDOM_AUDIT_SUGGESTED_PERCENTAGE : 0,
5677+
limit: enabled ? CONST.POLICY.AUTO_APPROVE_REPORTS_UNDER_SUGGESTED_CENTS : 0,
5678+
};
56765679
const autoApprovalFailureValues = {autoApproval: {limit: policy?.autoApproval?.limit, auditRate: policy?.autoApproval?.auditRate, pendingFields: null}};
56775680
const optimisticData: OnyxUpdate[] = [
56785681
{
@@ -5745,7 +5748,7 @@ function setPolicyAutoReimbursementLimit(policyID: string, limit: string) {
57455748
const fallbackLimit = limit === '' ? '0' : limit;
57465749
const parsedLimit = CurrencyUtils.convertToBackendAmount(parseFloat(fallbackLimit));
57475750

5748-
if (parsedLimit === (policy?.autoReimbursement?.limit ?? CONST.POLICY.AUTO_REIMBURSEMENT_DEFAULT_LIMIT_CENTS)) {
5751+
if (parsedLimit === (policy?.autoReimbursement?.limit ?? CONST.POLICY.AUTO_REIMBURSEMENT_LIMIT_DEFAULT_CENTS)) {
57495752
return;
57505753
}
57515754

@@ -5821,7 +5824,7 @@ function enablePolicyAutoReimbursementLimit(policyID: string, enabled: boolean)
58215824
}
58225825

58235826
const autoReimbursementFailureValues = {autoReimbursement: {limit: policy?.autoReimbursement?.limit, pendingFields: null}};
5824-
const autoReimbursementValues = {limit: CONST.POLICY.AUTO_REIMBURSEMENT_DEFAULT_LIMIT_CENTS};
5827+
const autoReimbursementValues = {limit: enabled ? CONST.POLICY.AUTO_REIMBURSEMENT_LIMIT_SUGGESTED_CENTS : CONST.POLICY.AUTO_REIMBURSEMENT_LIMIT_DEFAULT_CENTS};
58255828
const optimisticData: OnyxUpdate[] = [
58265829
{
58275830
onyxMethod: Onyx.METHOD.MERGE,

src/pages/workspace/rules/ExpenseReportRulesSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function ExpenseReportRulesSection({policyID}: ExpenseReportRulesSectionProps) {
116116
>
117117
<MenuItemWithTopDescription
118118
description={translate('workspace.rules.expenseReportRules.autoPayReportsUnderTitle')}
119-
title={convertToDisplayString(policy?.autoReimbursement?.limit ?? CONST.POLICY.AUTO_REIMBURSEMENT_DEFAULT_LIMIT_CENTS, policy?.outputCurrency ?? CONST.CURRENCY.USD)}
119+
title={convertToDisplayString(policy?.autoReimbursement?.limit ?? CONST.POLICY.AUTO_REIMBURSEMENT_LIMIT_DEFAULT_CENTS, policy?.outputCurrency ?? CONST.CURRENCY.USD)}
120120
shouldShowRightIcon
121121
style={[styles.sectionMenuItemTopDescription, styles.mt6, styles.mbn3]}
122122
onPress={() => Navigation.navigate(ROUTES.RULES_AUTO_PAY_REPORTS_UNDER.getRoute(policyID))}

src/pages/workspace/rules/RulesAutoPayReportsUnderPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function RulesAutoPayReportsUnderPage({route}: RulesAutoPayReportsUnderPageProps
3535
const currency = policy?.outputCurrency ?? CONST.CURRENCY.USD;
3636
const currencySymbol = getCurrencySymbol(currency);
3737
const autoPayApprovedReportsUnavailable = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO;
38-
const defaultValue = convertToFrontendAmountAsString(policy?.autoReimbursement?.limit ?? CONST.POLICY.AUTO_REIMBURSEMENT_DEFAULT_LIMIT_CENTS, policy?.outputCurrency);
38+
const defaultValue = convertToFrontendAmountAsString(policy?.autoReimbursement?.limit ?? CONST.POLICY.AUTO_REIMBURSEMENT_LIMIT_DEFAULT_CENTS, policy?.outputCurrency);
3939

4040
const validateLimit = ({maxExpenseAutoPayAmount}: FormOnyxValues<typeof ONYXKEYS.FORMS.RULES_AUTO_PAY_REPORTS_UNDER_MODAL_FORM>) => {
4141
const errors: FormInputErrors<typeof ONYXKEYS.FORMS.RULES_AUTO_PAY_REPORTS_UNDER_MODAL_FORM> = {};

0 commit comments

Comments
 (0)