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 ,
@@ -18,13 +18,10 @@ import {
1818 getParentReport ,
1919 getReportTransactions ,
2020 hasAnyViolations as hasAnyViolationsUtil ,
21- hasExportError as hasExportErrorUtil ,
2221 hasMissingSmartscanFields ,
23- hasReportBeenReopened ,
2422 isClosedReport ,
2523 isCurrentUserSubmitter ,
2624 isExpenseReport ,
27- isExported as isExportedUtil ,
2825 isInvoiceReport ,
2926 isIOUReport ,
3027 isOpenExpenseReport ,
@@ -38,14 +35,7 @@ import {
3835import { getSession } from './SessionUtils' ;
3936import { allHavePendingRTERViolation , isPending , isScanning , shouldShowBrokenConnectionViolationForMultipleTransactions } from './TransactionUtils' ;
4037
41- function canSubmit (
42- report : Report ,
43- violations : OnyxCollection < TransactionViolation [ ] > ,
44- isReportArchived : boolean ,
45- reportActions ?: OnyxEntry < ReportActions > | ReportAction [ ] ,
46- policy ?: Policy ,
47- transactions ?: Transaction [ ] ,
48- ) {
38+ function canSubmit ( report : Report , violations : OnyxCollection < TransactionViolation [ ] > , isReportArchived : boolean , policy ?: Policy , transactions ?: Transaction [ ] ) {
4939 if ( isReportArchived ) {
5040 return false ;
5141 }
@@ -55,7 +45,7 @@ function canSubmit(
5545 const isOpen = isOpenReport ( report ) ;
5646 const isManager = report . managerID === getCurrentUserAccountID ( ) ;
5747 const isAdmin = policy ?. role === CONST . POLICY . ROLE . ADMIN ;
58- const hasBeenReopened = hasReportBeenReopened ( reportActions ) ;
48+ const hasBeenReopened = report . hasReportBeenReopened ?? false ;
5949 const isManualSubmitEnabled = getCorrectedAutoReportingFrequency ( policy ) === CONST . POLICY . AUTO_REPORTING_FREQUENCIES . MANUAL ;
6050
6151 if ( ! ! transactions && transactions ?. length > 0 && transactions . every ( ( transaction ) => isPending ( transaction ) ) ) {
@@ -164,7 +154,7 @@ function canPay(
164154 return invoiceReceiverPolicy ?. role === CONST . POLICY . ROLE . ADMIN && reimbursableSpend > 0 ;
165155}
166156
167- function canExport ( report : Report , violations : OnyxCollection < TransactionViolation [ ] > , policy ?: Policy , reportActions ?: OnyxEntry < ReportActions > | ReportAction [ ] ) {
157+ function canExport ( report : Report , violations : OnyxCollection < TransactionViolation [ ] > , policy ?: Policy ) {
168158 const isExpense = isExpenseReport ( report ) ;
169159 const isExporter = policy ? isPreferredExporter ( policy ) : false ;
170160 const isReimbursed = isSettled ( report ) ;
@@ -178,12 +168,12 @@ function canExport(report: Report, violations: OnyxCollection<TransactionViolati
178168 return false ;
179169 }
180170
181- const isExported = isExportedUtil ( reportActions ) ;
171+ const isExported = report . isExportedToIntegration ?? false ;
182172 if ( isExported ) {
183173 return false ;
184174 }
185175
186- const hasExportError = hasExportErrorUtil ( reportActions ) ;
176+ const hasExportError = report . hasExportError ?? false ;
187177 if ( syncEnabled && ! hasExportError ) {
188178 return false ;
189179 }
@@ -234,7 +224,6 @@ function getReportPreviewAction(
234224 report ?: Report ,
235225 policy ?: Policy ,
236226 transactions ?: Transaction [ ] ,
237- reportActions ?: OnyxEntry < ReportActions > | ReportAction [ ] ,
238227 invoiceReceiverPolicy ?: Policy ,
239228) : ValueOf < typeof CONST . REPORT . REPORT_PREVIEW_ACTIONS > {
240229 if ( ! report ) {
@@ -243,7 +232,7 @@ function getReportPreviewAction(
243232 if ( isAddExpenseAction ( report , transactions ?? [ ] , isReportArchived ) ) {
244233 return CONST . REPORT . REPORT_PREVIEW_ACTIONS . ADD_EXPENSE ;
245234 }
246- if ( canSubmit ( report , violations , isReportArchived , reportActions , policy , transactions ) ) {
235+ if ( canSubmit ( report , violations , isReportArchived , policy , transactions ) ) {
247236 return CONST . REPORT . REPORT_PREVIEW_ACTIONS . SUBMIT ;
248237 }
249238 if ( canApprove ( report , violations , policy , transactions ) ) {
@@ -252,7 +241,7 @@ function getReportPreviewAction(
252241 if ( canPay ( report , violations , isReportArchived , policy , invoiceReceiverPolicy ) ) {
253242 return CONST . REPORT . REPORT_PREVIEW_ACTIONS . PAY ;
254243 }
255- if ( canExport ( report , violations , policy , reportActions ) ) {
244+ if ( canExport ( report , violations , policy ) ) {
256245 return CONST . REPORT . REPORT_PREVIEW_ACTIONS . EXPORT_TO_ACCOUNTING ;
257246 }
258247 if ( canReview ( report , violations , isReportArchived , policy , transactions ) ) {
0 commit comments