@@ -86,7 +86,16 @@ import Parser from '@libs/Parser';
8686import { getParsedMessageWithShortMentions } from '@libs/ParsingUtils' ;
8787import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils' ;
8888import * as PhoneNumber from '@libs/PhoneNumber' ;
89- import { getDefaultApprover , getMemberAccountIDsForWorkspace , getPolicy , isPaidGroupPolicy , isPolicyAdmin as isPolicyAdminPolicyUtils , isPolicyMember } from '@libs/PolicyUtils' ;
89+ import {
90+ getDefaultApprover ,
91+ getMemberAccountIDsForWorkspace ,
92+ getPolicy ,
93+ isInstantSubmitEnabled ,
94+ isPaidGroupPolicy ,
95+ isPolicyAdmin as isPolicyAdminPolicyUtils ,
96+ isPolicyMember ,
97+ isSubmitAndClose ,
98+ } from '@libs/PolicyUtils' ;
9099import processReportIDDeeplink from '@libs/processReportIDDeeplink' ;
91100import Pusher from '@libs/Pusher' ;
92101import type { UserIsLeavingRoomEvent , UserIsTypingEvent } from '@libs/Pusher/types' ;
@@ -5639,6 +5648,30 @@ function buildOptimisticChangePolicyData(
56395648 } ) ;
56405649 }
56415650
5651+ const isInstantSubmitEnabledLocal = isInstantSubmitEnabled ( policy ) ;
5652+ const isSubmitAndCloseLocal = isSubmitAndClose ( policy ) ;
5653+ const arePaymentsDisabled = policy ?. reimbursementChoice === CONST . POLICY . REIMBURSEMENT_CHOICES . REIMBURSEMENT_NO ;
5654+ if ( isProcessingReport ( report ) && isInstantSubmitEnabledLocal && isSubmitAndCloseLocal && arePaymentsDisabled ) {
5655+ newStatusNum = CONST . REPORT . STATUS_NUM . CLOSED ;
5656+ optimisticData . push ( {
5657+ onyxMethod : Onyx . METHOD . MERGE ,
5658+ key : `${ ONYXKEYS . COLLECTION . REPORT } ${ reportID } ` ,
5659+ value : {
5660+ stateNum : CONST . REPORT . STATE_NUM . APPROVED ,
5661+ statusNum : CONST . REPORT . STATUS_NUM . CLOSED ,
5662+ } ,
5663+ } ) ;
5664+
5665+ failureData . push ( {
5666+ onyxMethod : Onyx . METHOD . MERGE ,
5667+ key : `${ ONYXKEYS . COLLECTION . REPORT } ${ reportID } ` ,
5668+ value : {
5669+ stateNum : report . stateNum ,
5670+ statusNum : report . statusNum ,
5671+ } ,
5672+ } ) ;
5673+ }
5674+
56425675 if ( newStatusNum ) {
56435676 // buildOptimisticNextStep is used in parallel
56445677 // eslint-disable-next-line @typescript-eslint/no-deprecated
0 commit comments