Skip to content

Commit ba75636

Browse files
committed
fix: submit option is displayed for the auditor
1 parent d0dd99f commit ba75636

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

src/libs/ReportSecondaryActionUtils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,9 @@ function isSubmitAction(
146146
}
147147

148148
const isReportSubmitter = isCurrentUserSubmitter(report);
149-
const isReportApprover = isApproverUtils(policy, getCurrentUserAccountID());
150149
const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN;
151150
const isManager = report.managerID === getCurrentUserAccountID();
152-
if (!isReportSubmitter && !isReportApprover && !isAdmin && !isManager) {
151+
if (!isReportSubmitter && !isAdmin && !isManager) {
153152
return false;
154153
}
155154

tests/unit/ReportSecondaryActionUtilsTest.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,29 @@ describe('getSecondaryAction', () => {
118118
expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.SUBMIT)).toBe(true);
119119
});
120120

121+
it('should not include SUBMIT option for the user who is not submitter/admin/manager', async () => {
122+
const report: Report = {
123+
reportID: '1',
124+
type: CONST.REPORT.TYPE.EXPENSE,
125+
stateNum: CONST.REPORT.STATE_NUM.OPEN,
126+
statusNum: CONST.REPORT.STATUS_NUM.OPEN,
127+
total: 10,
128+
ownerAccountID: APPROVER_ACCOUNT_ID,
129+
managerID: 0,
130+
};
131+
const policy = {
132+
autoReportingFrequency: CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT,
133+
harvesting: {
134+
enabled: true,
135+
},
136+
role: CONST.POLICY.ROLE.AUDITOR,
137+
} as unknown as Policy;
138+
await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, report);
139+
140+
const result = getSecondaryReportActions({report, chatReport, reportTransactions: [], violations: {}, policy});
141+
expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.SUBMIT)).toBe(false);
142+
});
143+
121144
it('should not include SUBMIT option for admin with only pending transactions', async () => {
122145
const report = {
123146
reportID: REPORT_ID,

0 commit comments

Comments
 (0)