Skip to content

Commit 233a909

Browse files
committed
remove export option for invoices
1 parent 5c2873b commit 233a909

4 files changed

Lines changed: 36 additions & 6 deletions

File tree

src/libs/ReportPrimaryActionUtils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ function isExportAction(report: Report, policy?: Policy, reportActions?: ReportA
191191
}
192192

193193
const connectedIntegration = getValidConnectedIntegration(policy);
194-
if (!connectedIntegration) {
194+
const isInvoiceReport = isInvoiceReportUtils(report);
195+
196+
if (!connectedIntegration || isInvoiceReport) {
195197
return false;
196198
}
197199

src/libs/ReportSecondaryActionUtils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ function isExportAction(report: Report, policy?: Policy, reportActions?: ReportA
271271
}
272272

273273
const isInvoiceReport = isInvoiceReportUtils(report);
274-
const isReportSender = isCurrentUserSubmitter(report.reportID);
275274

276-
if (isInvoiceReport && isReportSender) {
277-
return true;
275+
// We don't allow export to accounting for invoice reports in OD so we want to align with that here.
276+
if (isInvoiceReport) {
277+
return false;
278278
}
279279

280280
const isExpenseReport = isExpenseReportUtils(report);

tests/unit/ReportPrimaryActionUtilsTest.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,34 @@ describe('getPrimaryAction', () => {
190190
);
191191
});
192192

193+
it('should not return EXPORT TO ACCOUNTING for invoice reports', async () => {
194+
const report = {
195+
reportID: REPORT_ID,
196+
type: CONST.REPORT.TYPE.INVOICE,
197+
ownerAccountID: CURRENT_USER_ACCOUNT_ID,
198+
statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
199+
} as unknown as Report;
200+
await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, report);
201+
const policy = {
202+
connections: {
203+
intacct: {
204+
config: {
205+
export: {
206+
exporter: CURRENT_USER_EMAIL,
207+
},
208+
},
209+
},
210+
},
211+
};
212+
const transaction = {
213+
reportID: `${REPORT_ID}`,
214+
} as unknown as Transaction;
215+
216+
expect(getReportPrimaryAction({report, chatReport, reportTransactions: [transaction], violations: {}, policy: policy as Policy})).not.toBe(
217+
CONST.REPORT.PRIMARY_ACTIONS.EXPORT_TO_ACCOUNTING,
218+
);
219+
});
220+
193221
it('should not return EXPORT TO ACCOUNTING for reports marked manually as exported', async () => {
194222
const report = {
195223
reportID: REPORT_ID,

tests/unit/ReportSecondaryActionUtilsTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ describe('getSecondaryAction', () => {
308308
expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.CANCEL_PAYMENT)).toBe(true);
309309
});
310310

311-
it('includes EXPORT option for invoice submitter', async () => {
311+
it('does not include EXPORT option for invoice reports', async () => {
312312
const report = {
313313
reportID: REPORT_ID,
314314
type: CONST.REPORT.TYPE.INVOICE,
@@ -322,7 +322,7 @@ describe('getSecondaryAction', () => {
322322
await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, report);
323323

324324
const result = getSecondaryReportActions({report, chatReport, reportTransactions: [], violations: {}, policy});
325-
expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.EXPORT_TO_ACCOUNTING)).toBe(true);
325+
expect(result.includes(CONST.REPORT.SECONDARY_ACTIONS.EXPORT_TO_ACCOUNTING)).toBe(false);
326326
});
327327

328328
it('includes EXPORT option for expense report with payments enabled', () => {

0 commit comments

Comments
 (0)