diff --git a/src/libs/actions/Policy/Category.ts b/src/libs/actions/Policy/Category.ts index 501b7cbbe1e5..5716eed8947d 100644 --- a/src/libs/actions/Policy/Category.ts +++ b/src/libs/actions/Policy/Category.ts @@ -1180,8 +1180,10 @@ function setPolicyCategoryApprover(policyID: string, categoryName: string, appro value: { rules: { approvalRules: updatedApprovalRules, - pendingFields: { - approvalRules: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + pendingRulesUpdates: { + [categoryName]: { + approvalRule: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, }, }, @@ -1192,9 +1194,9 @@ function setPolicyCategoryApprover(policyID: string, categoryName: string, appro onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { - rules: { - pendingFields: { - approvalRules: null, + pendingRulesUpdates: { + [categoryName]: { + approvalRule: null, }, }, }, @@ -1207,8 +1209,10 @@ function setPolicyCategoryApprover(policyID: string, categoryName: string, appro value: { rules: { approvalRules, - pendingFields: { - approvalRules: null, + }, + pendingRulesUpdates: { + [categoryName]: { + approvalRule: null, }, }, }, @@ -1260,8 +1264,10 @@ function setPolicyCategoryTax(policyID: string, categoryName: string, taxID: str value: { rules: { expenseRules: updatedExpenseRules, - pendingFields: { - expenseRules: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + pendingRulesUpdates: { + [categoryName]: { + expenseRule: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, }, }, }, @@ -1272,9 +1278,9 @@ function setPolicyCategoryTax(policyID: string, categoryName: string, taxID: str onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { - rules: { - pendingFields: { - expenseRules: null, + pendingRulesUpdates: { + [categoryName]: { + expenseRule: null, }, }, }, @@ -1287,8 +1293,10 @@ function setPolicyCategoryTax(policyID: string, categoryName: string, taxID: str value: { rules: { expenseRules, - pendingFields: { - expenseRules: null, + }, + pendingRulesUpdates: { + [categoryName]: { + expenseRule: null, }, }, }, diff --git a/src/pages/workspace/categories/CategorySettingsPage.tsx b/src/pages/workspace/categories/CategorySettingsPage.tsx index 0cac6b8a7bda..7e0eef8a7da8 100644 --- a/src/pages/workspace/categories/CategorySettingsPage.tsx +++ b/src/pages/workspace/categories/CategorySettingsPage.tsx @@ -257,7 +257,7 @@ function CategorySettingsPage({ /> )} - + )} {policy?.tax?.trackingEnabled && ( - + diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index f2604d723f05..95a9907526e4 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1412,6 +1412,9 @@ type ExpenseRule = { id?: string; }; +/** The name of the category or tag */ +type CategoryOrTagName = string; + /** Model of policy data */ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< { @@ -1586,13 +1589,13 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< taxRates?: TaxRatesWithDefault; /** A set of rules related to the workpsace */ - rules?: OnyxCommon.OnyxValueWithOfflineFeedback<{ + rules?: { /** A set of rules related to the workpsace approvals */ approvalRules?: ApprovalRule[]; /** A set of rules related to the workpsace expenses */ expenseRules?: ExpenseRule[]; - }>; + }; /** ReportID of the admins room for this workspace */ chatReportIDAdmins?: number; @@ -1683,6 +1686,18 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< /** Workspace account ID configured for Expensify Card */ workspaceAccountID?: number; + + /** Information about rules being updated */ + pendingRulesUpdates?: Record< + CategoryOrTagName, + { + /** Indicates whether the approval rule is updated for the given category or tag */ + approvalRule: OnyxCommon.PendingAction; + + /** Indicates whether the expense rule is updated for the given category or tag */ + expenseRule: OnyxCommon.PendingAction; + } + >; } & Partial, 'addWorkspaceRoom' | keyof ACHAccount | keyof Attributes >;