Skip to content

Commit

Permalink
put correct optimistic data for auto reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
lakchote committed Mar 8, 2024
1 parent c637b41 commit 531f0ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/libs/actions/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ function buildAnnounceRoomMembersOnyxData(policyID: string, accountIDs: number[]
return announceRoomMembers;
}

function setWorkspaceAutoReporting(policyID: string, enabled: boolean) {
function setWorkspaceAutoReporting(policyID: string, enabled: boolean, frequency: ValueOf<typeof CONST.POLICY.AUTO_REPORTING_FREQUENCIES>) {
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand All @@ -413,7 +413,7 @@ function setWorkspaceAutoReporting(policyID: string, enabled: boolean) {
harvesting: {
enabled: true,
},
autoReportingFrequency: CONST.POLICY.AUTO_REPORTING_FREQUENCIES.WEEKLY,
autoReportingFrequency: frequency,
pendingFields: {isAutoApprovalEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE},
},
},
Expand Down
5 changes: 4 additions & 1 deletion src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ function WorkspaceWorkflowsPage({policy, betas, route}: WorkspaceWorkflowsPagePr
title: translate('workflowsPage.delaySubmissionTitle'),
subtitle: translate('workflowsPage.delaySubmissionDescription'),
onToggle: (isEnabled: boolean) => {
Policy.setWorkspaceAutoReporting(route.params.policyID, isEnabled);
const frequency = policy?.autoReportingFrequency === CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT || !policy?.autoReportingFrequency
? CONST.POLICY.AUTO_REPORTING_FREQUENCIES.WEEKLY
: policy.autoReportingFrequency;
Policy.setWorkspaceAutoReporting(route.params.policyID, isEnabled, frequency);
},
subMenuItems: (
<MenuItem
Expand Down

0 comments on commit 531f0ca

Please sign in to comment.