@@ -317,7 +317,7 @@ function IOURequestStepScan({
317317 } , [ backTo ] ) ;
318318
319319 const navigateToConfirmationPage = useCallback (
320- ( isTestTransaction = false , reportIDParam : string | undefined = undefined ) => {
320+ ( shouldNavigateToSubmit = false , reportIDParam : string | undefined = undefined ) => {
321321 switch ( iouType ) {
322322 case CONST . IOU . TYPE . REQUEST :
323323 Navigation . navigate ( ROUTES . MONEY_REQUEST_STEP_CONFIRMATION . getRoute ( CONST . IOU . ACTION . CREATE , CONST . IOU . TYPE . SUBMIT , initialTransactionID , reportID , backToReport ) ) ;
@@ -329,7 +329,7 @@ function IOURequestStepScan({
329329 Navigation . navigate (
330330 ROUTES . MONEY_REQUEST_STEP_CONFIRMATION . getRoute (
331331 CONST . IOU . ACTION . CREATE ,
332- isTestTransaction ? CONST . IOU . TYPE . SUBMIT : iouType ,
332+ shouldNavigateToSubmit ? CONST . IOU . TYPE . SUBMIT : iouType ,
333333 initialTransactionID ,
334334 // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
335335 reportIDParam || reportID ,
@@ -503,17 +503,16 @@ function IOURequestStepScan({
503503 return ;
504504 }
505505
506- // If the initial transaction already has the participants selected, then we can skip the participants step and go straight to the confirmation step.
507- if ( initialTransaction ?. participants && initialTransaction ?. participants . length > 0 ) {
508- const setParticipantsPromises = files . map ( ( receiptFile ) => setMoneyRequestParticipants ( receiptFile . transactionID , initialTransaction ?. participants ) ) ;
509- Promise . all ( setParticipantsPromises ) . then ( ( ) => navigateToConfirmationPage ( false , initialTransaction ?. reportID ) ) ;
510- return ;
511- }
512-
513506 // If there was no reportID, then that means the user started this flow from the global + menu
514507 // and an optimistic reportID was generated. In that case, the next step is to select the participants for this expense.
515- if ( iouType === CONST . IOU . TYPE . CREATE && isPaidGroupPolicy ( activePolicy ) && activePolicy ?. isPolicyExpenseChatEnabled && ! shouldRestrictUserBillableActions ( activePolicy . id ) ) {
516- const activePolicyExpenseChat = getPolicyExpenseChat ( currentUserPersonalDetails . accountID , activePolicy ?. id ) ;
508+ const activePolicyExpenseChat = getPolicyExpenseChat ( currentUserPersonalDetails . accountID , activePolicy ?. id ) ;
509+ if (
510+ ( ! initialTransaction ?. participants || initialTransaction ?. participants ?. at ( 0 ) ?. reportID === activePolicyExpenseChat ?. reportID ) &&
511+ iouType === CONST . IOU . TYPE . CREATE &&
512+ isPaidGroupPolicy ( activePolicy ) &&
513+ activePolicy ?. isPolicyExpenseChatEnabled &&
514+ ! shouldRestrictUserBillableActions ( activePolicy . id )
515+ ) {
517516 const setParticipantsPromises = files . map ( ( receiptFile ) => setMoneyRequestParticipantsFromReport ( receiptFile . transactionID , activePolicyExpenseChat ) ) ;
518517 Promise . all ( setParticipantsPromises ) . then ( ( ) =>
519518 Navigation . navigate (
@@ -526,6 +525,12 @@ function IOURequestStepScan({
526525 ) ,
527526 ) ;
528527 } else {
528+ // If the initial transaction already has the participants selected, then we can skip the participants step and go straight to the confirmation step.
529+ if ( initialTransaction ?. participants && initialTransaction ?. participants . length > 0 ) {
530+ const setParticipantsPromises = files . map ( ( receiptFile ) => setMoneyRequestParticipants ( receiptFile . transactionID , initialTransaction ?. participants ) ) ;
531+ Promise . all ( setParticipantsPromises ) . then ( ( ) => navigateToConfirmationPage ( true , initialTransaction ?. reportID ) ) ;
532+ return ;
533+ }
529534 navigateToParticipantPage ( iouType , initialTransactionID , reportID ) ;
530535 }
531536 } ,
0 commit comments