@@ -16,7 +16,7 @@ import {
1616 isPreferredExporter ,
1717} from './PolicyUtils' ;
1818import { getIOUActionForReportID , getIOUActionForTransactionID , getOneTransactionThreadReportID , isPayAction } from './ReportActionsUtils' ;
19- import { isPrimaryPayAction } from './ReportPrimaryActionUtils' ;
19+ import { getReportPrimaryAction , isPrimaryPayAction } from './ReportPrimaryActionUtils' ;
2020import {
2121 canAddTransaction ,
2222 canEditReportPolicy ,
@@ -108,6 +108,7 @@ function isSubmitAction(
108108 reportNameValuePairs ?: ReportNameValuePairs ,
109109 reportActions ?: ReportAction [ ] ,
110110 isChatReportArchived = false ,
111+ primaryAction ?: ValueOf < typeof CONST . REPORT . PRIMARY_ACTIONS > | '' ,
111112) : boolean {
112113 if ( isArchivedReport ( reportNameValuePairs ) || isChatReportArchived ) {
113114 return false ;
@@ -160,7 +161,7 @@ function isSubmitAction(
160161
161162 const isScheduledSubmitEnabled = policy ?. harvesting ?. enabled && autoReportingFrequency !== CONST . POLICY . AUTO_REPORTING_FREQUENCIES . MANUAL ;
162163
163- return ! ! isScheduledSubmitEnabled ;
164+ return ! ! isScheduledSubmitEnabled || primaryAction !== CONST . REPORT . SECONDARY_ACTIONS . SUBMIT ;
164165}
165166
166167function isApproveAction ( report : Report , reportTransactions : Transaction [ ] , violations : OnyxCollection < TransactionViolation [ ] > , policy ?: Policy ) : boolean {
@@ -520,7 +521,18 @@ function getSecondaryReportActions({
520521 options . push ( CONST . REPORT . SECONDARY_ACTIONS . ADD_EXPENSE ) ;
521522 }
522523
523- if ( isSubmitAction ( report , reportTransactions , policy , reportNameValuePairs , reportActions , isChatReportArchived ) ) {
524+ const primaryAction = getReportPrimaryAction ( {
525+ report,
526+ chatReport,
527+ reportTransactions,
528+ violations,
529+ policy,
530+ reportNameValuePairs,
531+ reportActions,
532+ isChatReportArchived,
533+ } ) ;
534+
535+ if ( isSubmitAction ( report , reportTransactions , policy , reportNameValuePairs , reportActions , isChatReportArchived , primaryAction ) ) {
524536 options . push ( CONST . REPORT . SECONDARY_ACTIONS . SUBMIT ) ;
525537 }
526538
0 commit comments