Skip to content

Commit 6796be3

Browse files
authored
Merge pull request #37112 from Expensify/vit-updateSelfApprovalProp
[NoQA] Use preventSelfApprovalEnabled policy prop to match db format
2 parents 8d6c699 + 81c228d commit 6796be3

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

src/libs/NextStepUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function buildNextStep(
7373

7474
const {policyID = '', ownerAccountID = -1, managerID = -1} = report;
7575
const policy = ReportUtils.getPolicy(policyID);
76-
const {submitsTo, harvesting, isPreventSelfApprovalEnabled, autoReportingFrequency, autoReportingOffset} = policy;
76+
const {submitsTo, harvesting, isPreventSelfApprovalEnabled, preventSelfApprovalEnabled, autoReportingFrequency, autoReportingOffset} = policy;
7777
const isOwner = currentUserAccountID === ownerAccountID;
7878
const isManager = currentUserAccountID === managerID;
7979
const isSelfApproval = currentUserAccountID === submitsTo;
@@ -164,7 +164,7 @@ function buildNextStep(
164164
}
165165

166166
// Prevented self submitting
167-
if (isPreventSelfApprovalEnabled && isSelfApproval) {
167+
if ((isPreventSelfApprovalEnabled ?? preventSelfApprovalEnabled) && isSelfApproval) {
168168
optimisticNextStep.message = [
169169
{
170170
text: "Oops! Looks like you're submitting to ",

src/types/onyx/Policy.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,12 @@ type Policy = {
105105
enabled: boolean;
106106
};
107107

108-
/** Whether the self approval or submitting is enabled */
108+
/** @deprecated Whether the self approval or submitting is enabled */
109109
isPreventSelfApprovalEnabled?: boolean;
110110

111+
/** Whether the self approval or submitting is enabled */
112+
preventSelfApprovalEnabled?: boolean;
113+
111114
/** When the monthly scheduled submit should happen */
112115
autoReportingOffset?: AutoReportingOffset;
113116

tests/unit/NextStepUtilsTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ describe('libs/NextStepUtils', () => {
340340

341341
return Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {
342342
submitsTo: currentUserAccountID,
343-
isPreventSelfApprovalEnabled: true,
343+
preventSelfApprovalEnabled: true,
344344
}).then(() => {
345345
const result = NextStepUtils.buildNextStep(report, CONST.REPORT.STATUS_NUM.OPEN);
346346

tests/utils/LHNTestUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ function getFakePolicy(id = 1, name = 'Workspace-Test-001') {
259259
enabled: true,
260260
},
261261
autoReportingOffset: 1,
262-
isPreventSelfApprovalEnabled: true,
262+
preventSelfApprovalEnabled: true,
263263
submitsTo: 123456,
264264
defaultBillable: false,
265265
disabledFields: {defaultBillable: true, reimbursable: false},

tests/utils/collections/policies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default function createRandomPolicy(index: number): Policy {
1414
enabled: randBoolean(),
1515
},
1616
autoReportingOffset: 1,
17-
isPreventSelfApprovalEnabled: randBoolean(),
17+
preventSelfApprovalEnabled: randBoolean(),
1818
submitsTo: index,
1919
outputCurrency: randCurrencyCode(),
2020
role: rand(Object.values(CONST.POLICY.ROLE)),

0 commit comments

Comments
 (0)