Skip to content

Commit

Permalink
Remove unnecessary edge case for policy admins
Browse files Browse the repository at this point in the history
  • Loading branch information
roryabraham committed Apr 3, 2024
1 parent 6f4cf0f commit 2252a6c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
7 changes: 0 additions & 7 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,6 @@ function hasOutstandingChildRequest(report: OnyxTypes.Report, policy: OnyxEntry<
return true;
}

// If the user is a policy admin, they can approve and pay the report themselves.
// So even if the report will be automatically submitted, the next step would need to be done by them anyway.
// In this case, we show a green dot because they don't need to wait for harvesting to submit.
if (ReportUtils.isExpenseReport(report) && PolicyUtils.isPolicyAdmin(policy)) {
return true;
}

return report.managerID === userAccountID && report.total !== 0;
}

Expand Down
16 changes: 1 addition & 15 deletions tests/actions/IOUTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3310,7 +3310,7 @@ describe('actions/IOU', () => {
await Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, policy);
expect(IOU.hasOutstandingChildRequest(report, policy)).toBe(true);
});
it('should return true if an expense report does not need to be manually submitted, but the user is a policy admin', async () => {
it('should return false if an expense report does not need to be manually submitted', async () => {
const policy = {
...LHNTestUtils.getFakePolicy(),
type: CONST.POLICY.TYPE.TEAM,
Expand All @@ -3321,20 +3321,6 @@ describe('actions/IOU', () => {
policyID: policy.id,
};
await Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, policy);
expect(IOU.hasOutstandingChildRequest(report, policy)).toBe(true);
});
it('should return false if an expense report does not need to be manually submitted, and the user is not a policy admin', async () => {
const policy = {
...LHNTestUtils.getFakePolicy(),
type: CONST.POLICY.TYPE.TEAM,
role: CONST.POLICY.ROLE.USER,
};
const report = {
...LHNTestUtils.getFakeReport(),
type: CONST.REPORT.TYPE.EXPENSE,
policyID: policy.id,
};
await Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${policy.id}`, policy);
expect(IOU.hasOutstandingChildRequest(report, policy)).toBe(false);
});
it('should return false for an IOU report where no money is owed', async () => {
Expand Down

0 comments on commit 2252a6c

Please sign in to comment.