diff --git a/src/libs/actions/Policy.ts b/src/libs/actions/Policy.ts index dbbb94b82a1a..8df84965b08c 100644 --- a/src/libs/actions/Policy.ts +++ b/src/libs/actions/Policy.ts @@ -451,7 +451,7 @@ function setWorkspaceAutoReporting(policyID: string, enabled: boolean, frequency enabled, }, autoReportingFrequency: frequency, - pendingFields: {isAutoApprovalEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}, + pendingFields: {autoReporting: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}, }, }, ]; @@ -466,7 +466,7 @@ function setWorkspaceAutoReporting(policyID: string, enabled: boolean, frequency enabled: policy.harvesting?.enabled ?? null, }, autoReportingFrequency: policy.autoReportingFrequency ?? null, - pendingFields: {isAutoApprovalEnabled: null, harvesting: null}, + pendingFields: {autoReporting: null}, }, }, ]; @@ -476,7 +476,7 @@ function setWorkspaceAutoReporting(policyID: string, enabled: boolean, frequency onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, value: { - pendingFields: {isAutoApprovalEnabled: null, harvesting: null}, + pendingFields: {autoReporting: null}, }, }, ]; @@ -566,13 +566,11 @@ function setWorkspaceAutoReportingMonthlyOffset(policyID: string, autoReportingO } function setWorkspaceApprovalMode(policyID: string, approver: string, approvalMode: ValueOf) { - const isAutoApprovalEnabled = approvalMode === CONST.POLICY.APPROVAL_MODE.BASIC; const policy = ReportUtils.getPolicy(policyID); const value = { approver, approvalMode, - isAutoApprovalEnabled, }; const optimisticData: OnyxUpdate[] = [ @@ -593,7 +591,6 @@ function setWorkspaceApprovalMode(policyID: string, approver: string, approvalMo value: { approver: policy.approver ?? null, approvalMode: policy.approvalMode ?? null, - isAutoApprovalEnabled: policy.isAutoApprovalEnabled ?? null, pendingFields: {approvalMode: null}, }, }, @@ -609,7 +606,14 @@ function setWorkspaceApprovalMode(policyID: string, approver: string, approvalMo }, ]; - const params: SetWorkspaceApprovalModeParams = {policyID, value: JSON.stringify(value)}; + const params: SetWorkspaceApprovalModeParams = { + policyID, + value: JSON.stringify({ + ...value, + // This property should now be set to false for all Collect policies + isAutoApprovalEnabled: false, + }), + }; API.write(WRITE_COMMANDS.SET_WORKSPACE_APPROVAL_MODE, params, {optimisticData, failureData, successData}); } diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index c6ace2b0856e..af91eeb3aef6 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -111,7 +111,7 @@ function WorkspaceWorkflowsPage({policy, betas, route, reimbursementAccount, ses /> ), isActive: (policy?.harvesting?.enabled && policy.autoReportingFrequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT) ?? false, - pendingAction: policy?.pendingFields?.isAutoApprovalEnabled, + pendingAction: policy?.pendingFields?.autoReporting, }, ] : []), @@ -134,7 +134,7 @@ function WorkspaceWorkflowsPage({policy, betas, route, reimbursementAccount, ses hoverAndPressStyle={[styles.mr0, styles.br2]} /> ), - isActive: policy?.isAutoApprovalEnabled ?? false, + isActive: policy?.approvalMode === CONST.POLICY.APPROVAL_MODE.BASIC, pendingAction: policy?.pendingFields?.approvalMode, }, { diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 84ac101a7d7a..e8e17bbdff4b 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -292,9 +292,6 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< /** The approval mode set up on this policy */ approvalMode?: ValueOf; - /** Whether the auto approval is enabled */ - isAutoApprovalEnabled?: boolean; - /** Whether transactions should be billable by default */ defaultBillable?: boolean;