@@ -20,6 +20,7 @@ import {
2020 hasExportError as hasExportErrorUtil ,
2121 hasMissingSmartscanFields ,
2222 hasNoticeTypeViolations ,
23+ hasReportBeenReopened ,
2324 hasViolations ,
2425 hasWarningTypeViolations ,
2526 isClosedReport ,
@@ -39,7 +40,14 @@ import {
3940import { getSession } from './SessionUtils' ;
4041import { allHavePendingRTERViolation , isScanning , shouldShowBrokenConnectionViolationForMultipleTransactions } from './TransactionUtils' ;
4142
42- function canSubmit ( report : Report , violations : OnyxCollection < TransactionViolation [ ] > , policy ?: Policy , transactions ?: Transaction [ ] , isReportArchived = false ) {
43+ function canSubmit (
44+ report : Report ,
45+ violations : OnyxCollection < TransactionViolation [ ] > ,
46+ reportActions ?: OnyxEntry < ReportActions > | ReportAction [ ] ,
47+ policy ?: Policy ,
48+ transactions ?: Transaction [ ] ,
49+ isReportArchived = false ,
50+ ) {
4351 if ( isReportArchived ) {
4452 return false ;
4553 }
@@ -49,7 +57,9 @@ function canSubmit(report: Report, violations: OnyxCollection<TransactionViolati
4957 const isOpen = isOpenReport ( report ) ;
5058 const isManager = report . managerID === getCurrentUserAccountID ( ) ;
5159 const isAdmin = policy ?. role === CONST . POLICY . ROLE . ADMIN ;
60+ const hasBeenReopened = hasReportBeenReopened ( reportActions ) ;
5261 const isManualSubmitEnabled = getCorrectedAutoReportingFrequency ( policy ) === CONST . POLICY . AUTO_REPORTING_FREQUENCIES . MANUAL ;
62+
5363 const hasAnyViolations =
5464 hasMissingSmartscanFields ( report . reportID , transactions ) ||
5565 hasViolations ( report . reportID , violations ) ||
@@ -63,7 +73,14 @@ function canSubmit(report: Report, violations: OnyxCollection<TransactionViolati
6373 return false ;
6474 }
6575
66- return isExpense && ( isSubmitter || isManager || isAdmin ) && isOpen && isManualSubmitEnabled && ! hasAnyViolations && ! isAnyReceiptBeingScanned ;
76+ const baseCanSubmit = isExpense && ( isSubmitter || isManager || isAdmin ) && isOpen && ! hasAnyViolations && ! isAnyReceiptBeingScanned ;
77+
78+ // If a report has been reopened, we allow submission regardless of the auto reporting frequency.
79+ if ( baseCanSubmit && hasBeenReopened ) {
80+ return true ;
81+ }
82+
83+ return baseCanSubmit && isManualSubmitEnabled ;
6784}
6885
6986function canApprove ( report : Report , violations : OnyxCollection < TransactionViolation [ ] > , policy ?: Policy , transactions ?: Transaction [ ] , shouldConsiderViolations = true ) {
@@ -234,7 +251,7 @@ function getReportPreviewAction(
234251 if ( isAddExpenseAction ( report , transactions ?? [ ] , isReportArchived ) ) {
235252 return CONST . REPORT . REPORT_PREVIEW_ACTIONS . ADD_EXPENSE ;
236253 }
237- if ( canSubmit ( report , violations , policy , transactions , isReportArchived ) ) {
254+ if ( canSubmit ( report , violations , reportActions , policy , transactions , isReportArchived ) ) {
238255 return CONST . REPORT . REPORT_PREVIEW_ACTIONS . SUBMIT ;
239256 }
240257 if ( canApprove ( report , violations , policy , transactions ) ) {
0 commit comments