diff --git a/src/libs/CategoryUtils.ts b/src/libs/CategoryUtils.ts index 479ae557eab6..789026f91af6 100644 --- a/src/libs/CategoryUtils.ts +++ b/src/libs/CategoryUtils.ts @@ -24,9 +24,9 @@ function formatDefaultTaxRateText(translate: LocaleContextProps['translate'], ta return `${taxRateText}${suffix ? ` ${CONST.DOT_SEPARATOR} ${suffix}` : ``}`; } -function formatRequireReceiptsOverText(translate: LocaleContextProps['translate'], policy: Policy, categoryMaxExpenseAmountNoReceipt?: number | null) { - const isAlwaysSelected = categoryMaxExpenseAmountNoReceipt === 0; - const isNeverSelected = categoryMaxExpenseAmountNoReceipt === CONST.DISABLED_MAX_EXPENSE_VALUE; +function formatRequireReceiptsOverText(translate: LocaleContextProps['translate'], policy: Policy, categoryMaxAmountNoReceipt?: number | null) { + const isAlwaysSelected = categoryMaxAmountNoReceipt === 0; + const isNeverSelected = categoryMaxAmountNoReceipt === CONST.DISABLED_MAX_EXPENSE_VALUE; if (isAlwaysSelected) { return translate(`workspace.rules.categoryRules.requireReceiptsOverList.always`); diff --git a/src/libs/actions/Policy/Category.ts b/src/libs/actions/Policy/Category.ts index 78b0f2dec9e2..e0546e7d74ff 100644 --- a/src/libs/actions/Policy/Category.ts +++ b/src/libs/actions/Policy/Category.ts @@ -390,8 +390,8 @@ function setPolicyCategoryDescriptionRequired(policyID: string, categoryName: st API.write(WRITE_COMMANDS.SET_POLICY_CATEGORY_DESCRIPTION_REQUIRED, parameters, onyxData); } -function setPolicyCategoryReceiptsRequired(policyID: string, categoryName: string, maxExpenseAmountNoReceipt: number) { - const originalMaxExpenseAmountNoReceipt = allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`]?.[categoryName]?.maxExpenseAmountNoReceipt; +function setPolicyCategoryReceiptsRequired(policyID: string, categoryName: string, maxAmountNoReceipt: number) { + const originalMaxAmountNoReceipt = allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`]?.[categoryName]?.maxAmountNoReceipt; const onyxData: OnyxData = { optimisticData: [ @@ -402,9 +402,9 @@ function setPolicyCategoryReceiptsRequired(policyID: string, categoryName: strin [categoryName]: { pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, pendingFields: { - maxExpenseAmountNoReceipt: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + maxAmountNoReceipt: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, - maxExpenseAmountNoReceipt, + maxAmountNoReceipt, }, }, }, @@ -417,9 +417,9 @@ function setPolicyCategoryReceiptsRequired(policyID: string, categoryName: strin [categoryName]: { pendingAction: null, pendingFields: { - maxExpenseAmountNoReceipt: null, + maxAmountNoReceipt: null, }, - maxExpenseAmountNoReceipt, + maxAmountNoReceipt, }, }, }, @@ -433,9 +433,9 @@ function setPolicyCategoryReceiptsRequired(policyID: string, categoryName: strin errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), pendingAction: null, pendingFields: { - maxExpenseAmountNoReceipt: null, + maxAmountNoReceipt: null, }, - maxExpenseAmountNoReceipt: originalMaxExpenseAmountNoReceipt, + maxAmountNoReceipt: originalMaxAmountNoReceipt, }, }, }, @@ -445,14 +445,14 @@ function setPolicyCategoryReceiptsRequired(policyID: string, categoryName: strin const parameters: SetPolicyCategoryReceiptsRequiredParams = { policyID, categoryName, - maxExpenseAmountNoReceipt, + maxExpenseAmountNoReceipt: maxAmountNoReceipt, }; API.write(WRITE_COMMANDS.SET_POLICY_CATEGORY_RECEIPTS_REQUIRED, parameters, onyxData); } function removePolicyCategoryReceiptsRequired(policyID: string, categoryName: string) { - const originalMaxExpenseAmountNoReceipt = allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`]?.[categoryName]?.maxExpenseAmountNoReceipt; + const originalMaxAmountNoReceipt = allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`]?.[categoryName]?.maxAmountNoReceipt; const onyxData: OnyxData = { optimisticData: [ @@ -463,9 +463,9 @@ function removePolicyCategoryReceiptsRequired(policyID: string, categoryName: st [categoryName]: { pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, pendingFields: { - maxExpenseAmountNoReceipt: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + maxAmountNoReceipt: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, - maxExpenseAmountNoReceipt: null, + maxAmountNoReceipt: null, }, }, }, @@ -478,9 +478,9 @@ function removePolicyCategoryReceiptsRequired(policyID: string, categoryName: st [categoryName]: { pendingAction: null, pendingFields: { - maxExpenseAmountNoReceipt: null, + maxAmountNoReceipt: null, }, - maxExpenseAmountNoReceipt: null, + maxAmountNoReceipt: null, }, }, }, @@ -494,9 +494,9 @@ function removePolicyCategoryReceiptsRequired(policyID: string, categoryName: st errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), pendingAction: null, pendingFields: { - maxExpenseAmountNoReceipt: null, + maxAmountNoReceipt: null, }, - maxExpenseAmountNoReceipt: originalMaxExpenseAmountNoReceipt, + maxAmountNoReceipt: originalMaxAmountNoReceipt, }, }, }, diff --git a/src/pages/workspace/categories/CategoryRequireReceiptsOverPage.tsx b/src/pages/workspace/categories/CategoryRequireReceiptsOverPage.tsx index 7d526ede42b5..d24cda38c461 100644 --- a/src/pages/workspace/categories/CategoryRequireReceiptsOverPage.tsx +++ b/src/pages/workspace/categories/CategoryRequireReceiptsOverPage.tsx @@ -43,8 +43,8 @@ function CategoryRequireReceiptsOverPage({ const policy = usePolicy(policyID); const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`); - const isAlwaysSelected = policyCategories?.[categoryName]?.maxExpenseAmountNoReceipt === 0; - const isNeverSelected = policyCategories?.[categoryName]?.maxExpenseAmountNoReceipt === CONST.DISABLED_MAX_EXPENSE_VALUE; + const isAlwaysSelected = policyCategories?.[categoryName]?.maxAmountNoReceipt === 0; + const isNeverSelected = policyCategories?.[categoryName]?.maxAmountNoReceipt === CONST.DISABLED_MAX_EXPENSE_VALUE; const maxExpenseAmountToDisplay = policy?.maxExpenseAmount === CONST.DISABLED_MAX_EXPENSE_VALUE ? 0 : policy?.maxExpenseAmount; const requireReceiptsOverListData = [ diff --git a/src/pages/workspace/categories/CategorySettingsPage.tsx b/src/pages/workspace/categories/CategorySettingsPage.tsx index 499a47c01abe..9bc7bf615d96 100644 --- a/src/pages/workspace/categories/CategorySettingsPage.tsx +++ b/src/pages/workspace/categories/CategorySettingsPage.tsx @@ -102,8 +102,8 @@ function CategorySettingsPage({ if (!policy) { return ''; } - return CategoryUtils.formatRequireReceiptsOverText(translate, policy, policyCategory?.maxExpenseAmountNoReceipt); - }, [policy, policyCategory?.maxExpenseAmountNoReceipt, translate]); + return CategoryUtils.formatRequireReceiptsOverText(translate, policy, policyCategory?.maxAmountNoReceipt); + }, [policy, policyCategory?.maxAmountNoReceipt, translate]); if (!policyCategory) { return ; @@ -308,7 +308,7 @@ function CategorySettingsPage({ shouldShowRightIcon /> - + ; /** Record of policy categories, indexed by their name */