Skip to content

Commit

Permalink
add null value as a fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanDylann committed Mar 13, 2024
1 parent 3eebe66 commit 750ca3f
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/libs/actions/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,11 @@ function setWorkspaceAutoReporting(policyID: string, enabled: boolean, frequency
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
autoReporting: policy.autoReporting,
harvesting: policy.harvesting,
autoReportingFrequency: policy.autoReportingFrequency,
autoReporting: policy.autoReporting ?? null,
harvesting: {
enabled: policy?.harvesting?.enabled ?? null,
},
autoReportingFrequency: policy.autoReportingFrequency ?? null,
pendingFields: {isAutoApprovalEnabled: null, harvesting: null},
},
},
Expand Down Expand Up @@ -499,7 +501,7 @@ function setWorkspaceAutoReportingFrequency(policyID: string, frequency: ValueOf
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
autoReportingFrequency: policy.autoReportingFrequency,
autoReportingFrequency: policy.autoReportingFrequency ?? null,
pendingFields: {autoReportingFrequency: null},
},
},
Expand Down Expand Up @@ -539,7 +541,7 @@ function setWorkspaceAutoReportingMonthlyOffset(policyID: string, autoReportingO
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
autoReportingOffset: policy.autoReportingOffset,
autoReportingOffset: policy.autoReportingOffset ?? null,
pendingFields: {autoReportingOffset: null},
},
},
Expand Down Expand Up @@ -585,9 +587,9 @@ function setWorkspaceApprovalMode(policyID: string, approver: string, approvalMo
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
approver: policy.approver,
approvalMode: policy.approvalMode,
isAutoApprovalEnabled: policy.isAutoApprovalEnabled,
approver: policy.approver ?? null,
approvalMode: policy.approvalMode ?? null,
isAutoApprovalEnabled: policy.isAutoApprovalEnabled ?? null,
pendingFields: {approvalMode: null},
},
},
Expand Down Expand Up @@ -639,8 +641,8 @@ function setWorkspacePayer(policyID: string, reimburserEmail: string, reimburser
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
reimburserEmail: policy.reimburserEmail,
reimburserAccountID: policy.reimburserAccountID,
reimburserEmail: policy.reimburserEmail ?? null,
reimburserAccountID: policy.reimburserAccountID ?? null,
errorFields: {reimburserEmail: ErrorUtils.getMicroSecondOnyxError('workflowsPayerPage.genericErrorMessage')},
pendingFields: {reimburserEmail: null},
},
Expand Down Expand Up @@ -689,9 +691,9 @@ function setWorkspaceReimbursement(policyID: string, reimbursementChoice: ValueO
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
reimbursementChoice: policy.reimbursementChoice,
reimburserAccountID: policy.reimburserAccountID,
reimburserEmail: policy.reimburserEmail,
reimbursementChoice: policy.reimbursementChoice ?? null,
reimburserAccountID: policy.reimburserAccountID ?? null,
reimburserEmail: policy.reimburserEmail ?? null,
errorFields: {reimbursementChoice: ErrorUtils.getMicroSecondOnyxError('common.genericErrorMessage')},
pendingFields: {reimbursementChoice: null},
},
Expand Down

0 comments on commit 750ca3f

Please sign in to comment.