1- import type { OnyxCollection , OnyxEntry } from 'react-native-onyx' ;
1+ import type { OnyxCollection } from 'react-native-onyx' ;
22import type { ValueOf } from 'type-fest' ;
33import CONST from '@src/CONST' ;
4- import type { Policy , Report , ReportAction , ReportActions , Transaction , TransactionViolation } from '@src/types/onyx' ;
4+ import type { Policy , Report , Transaction , TransactionViolation } from '@src/types/onyx' ;
55import { getCurrentUserAccountID } from './actions/Report' ;
66import {
77 arePaymentsEnabled ,
@@ -17,16 +17,13 @@ import {
1717 getMoneyRequestSpendBreakdown ,
1818 getParentReport ,
1919 getReportTransactions ,
20- hasExportError as hasExportErrorUtil ,
2120 hasMissingSmartscanFields ,
2221 hasNoticeTypeViolations ,
23- hasReportBeenReopened ,
2422 hasViolations ,
2523 hasWarningTypeViolations ,
2624 isClosedReport ,
2725 isCurrentUserSubmitter ,
2826 isExpenseReport ,
29- isExported as isExportedUtil ,
3027 isInvoiceReport ,
3128 isIOUReport ,
3229 isOpenExpenseReport ,
@@ -43,7 +40,6 @@ import {allHavePendingRTERViolation, isPending, isScanning, shouldShowBrokenConn
4340function canSubmit (
4441 report : Report ,
4542 violations : OnyxCollection < TransactionViolation [ ] > ,
46- reportActions ?: OnyxEntry < ReportActions > | ReportAction [ ] ,
4743 policy ?: Policy ,
4844 transactions ?: Transaction [ ] ,
4945 isReportArchived = false ,
@@ -57,7 +53,7 @@ function canSubmit(
5753 const isOpen = isOpenReport ( report ) ;
5854 const isManager = report . managerID === getCurrentUserAccountID ( ) ;
5955 const isAdmin = policy ?. role === CONST . POLICY . ROLE . ADMIN ;
60- const hasBeenReopened = hasReportBeenReopened ( reportActions ) ;
56+ const hasBeenReopened = report . hasReportBeenReopened ?? false ;
6157 const isManualSubmitEnabled = getCorrectedAutoReportingFrequency ( policy ) === CONST . POLICY . AUTO_REPORTING_FREQUENCIES . MANUAL ;
6258
6359 if ( ! ! transactions && transactions ?. length > 0 && transactions . every ( ( transaction ) => isPending ( transaction ) ) ) {
@@ -171,7 +167,7 @@ function canPay(
171167 return invoiceReceiverPolicy ?. role === CONST . POLICY . ROLE . ADMIN && reimbursableSpend > 0 ;
172168}
173169
174- function canExport ( report : Report , violations : OnyxCollection < TransactionViolation [ ] > , policy ?: Policy , reportActions ?: OnyxEntry < ReportActions > | ReportAction [ ] ) {
170+ function canExport ( report : Report , violations : OnyxCollection < TransactionViolation [ ] > , policy ?: Policy ) {
175171 const isExpense = isExpenseReport ( report ) ;
176172 const isExporter = policy ? isPreferredExporter ( policy ) : false ;
177173 const isReimbursed = isSettled ( report ) ;
@@ -186,12 +182,12 @@ function canExport(report: Report, violations: OnyxCollection<TransactionViolati
186182 return false ;
187183 }
188184
189- const isExported = isExportedUtil ( reportActions ) ;
185+ const isExported = report . isExportedToIntegration ?? false ;
190186 if ( isExported ) {
191187 return false ;
192188 }
193189
194- const hasExportError = hasExportErrorUtil ( reportActions ) ;
190+ const hasExportError = report . hasExportError ?? false ;
195191 if ( syncEnabled && ! hasExportError ) {
196192 return false ;
197193 }
@@ -246,7 +242,6 @@ function getReportPreviewAction(
246242 policy ?: Policy ,
247243 transactions ?: Transaction [ ] ,
248244 isReportArchived = false ,
249- reportActions ?: OnyxEntry < ReportActions > | ReportAction [ ] ,
250245 invoiceReceiverPolicy ?: Policy ,
251246) : ValueOf < typeof CONST . REPORT . REPORT_PREVIEW_ACTIONS > {
252247 if ( ! report ) {
@@ -255,7 +250,7 @@ function getReportPreviewAction(
255250 if ( isAddExpenseAction ( report , transactions ?? [ ] , isReportArchived ) ) {
256251 return CONST . REPORT . REPORT_PREVIEW_ACTIONS . ADD_EXPENSE ;
257252 }
258- if ( canSubmit ( report , violations , reportActions , policy , transactions , isReportArchived ) ) {
253+ if ( canSubmit ( report , violations , policy , transactions , isReportArchived ) ) {
259254 return CONST . REPORT . REPORT_PREVIEW_ACTIONS . SUBMIT ;
260255 }
261256 if ( canApprove ( report , violations , policy , transactions ) ) {
@@ -264,7 +259,7 @@ function getReportPreviewAction(
264259 if ( canPay ( report , violations , policy , isReportArchived , invoiceReceiverPolicy ) ) {
265260 return CONST . REPORT . REPORT_PREVIEW_ACTIONS . PAY ;
266261 }
267- if ( canExport ( report , violations , policy , reportActions ) ) {
262+ if ( canExport ( report , violations , policy ) ) {
268263 return CONST . REPORT . REPORT_PREVIEW_ACTIONS . EXPORT_TO_ACCOUNTING ;
269264 }
270265 if ( canReview ( report , violations , policy , transactions , isReportArchived ) ) {
0 commit comments