Skip to content

Commit

Permalink
Merge pull request #37837 from Expensify/yuwen-preventSelfApproval
Browse files Browse the repository at this point in the history
[NoQA] Fix `preventSelfApprovalEnabled` policy property, it should be `preventSelfApproval`
  • Loading branch information
mountiny authored Mar 8, 2024
2 parents 401bb21 + 5c9ff40 commit bcc1749
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/libs/NextStepUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function buildNextStep(

const {policyID = '', ownerAccountID = -1, managerID = -1} = report;
const policy = ReportUtils.getPolicy(policyID);
const {submitsTo, harvesting, isPreventSelfApprovalEnabled, preventSelfApprovalEnabled, autoReportingFrequency, autoReportingOffset} = policy;
const {submitsTo, harvesting, isPreventSelfApprovalEnabled, preventSelfApproval, autoReportingFrequency, autoReportingOffset} = policy;
const isOwner = currentUserAccountID === ownerAccountID;
const isManager = currentUserAccountID === managerID;
const isSelfApproval = currentUserAccountID === submitsTo;
Expand Down Expand Up @@ -164,7 +164,7 @@ function buildNextStep(
}

// Prevented self submitting
if ((isPreventSelfApprovalEnabled ?? preventSelfApprovalEnabled) && isSelfApproval) {
if ((isPreventSelfApprovalEnabled ?? preventSelfApproval) && isSelfApproval) {
optimisticNextStep.message = [
{
text: "Oops! Looks like you're submitting to ",
Expand Down
2 changes: 1 addition & 1 deletion src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback<
isPreventSelfApprovalEnabled?: boolean;

/** Whether the self approval or submitting is enabled */
preventSelfApprovalEnabled?: boolean;
preventSelfApproval?: boolean;

/** When the monthly scheduled submit should happen */
autoReportingOffset?: AutoReportingOffset;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/NextStepUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ describe('libs/NextStepUtils', () => {

return Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {
submitsTo: currentUserAccountID,
preventSelfApprovalEnabled: true,
preventSelfApproval: true,
}).then(() => {
const result = NextStepUtils.buildNextStep(report, CONST.REPORT.STATUS_NUM.OPEN);

Expand Down
2 changes: 1 addition & 1 deletion tests/utils/LHNTestUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ function getFakePolicy(id = '1', name = 'Workspace-Test-001'): Policy {
enabled: true,
},
autoReportingOffset: 1,
preventSelfApprovalEnabled: true,
preventSelfApproval: true,
submitsTo: 123456,
defaultBillable: false,
disabledFields: {defaultBillable: true, reimbursable: false},
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/collections/policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function createRandomPolicy(index: number): Policy {
enabled: randBoolean(),
},
autoReportingOffset: 1,
preventSelfApprovalEnabled: randBoolean(),
preventSelfApproval: randBoolean(),
submitsTo: index,
outputCurrency: randCurrencyCode(),
role: rand(Object.values(CONST.POLICY.ROLE)),
Expand Down

0 comments on commit bcc1749

Please sign in to comment.