@@ -121,7 +121,7 @@ function IOURequestStepScan({
121121 const [ dismissedProductTraining ] = useOnyx ( ONYXKEYS . NVP_DISMISSED_PRODUCT_TRAINING , { canBeMissing : true } ) ;
122122 const isEditing = action === CONST . IOU . ACTION . EDIT ;
123123 const canUseMultiScan = isBetaEnabled ( CONST . BETAS . NEWDOT_MULTI_SCAN ) && ! isEditing && iouType !== CONST . IOU . TYPE . SPLIT && ! backTo && ! backToReport ;
124- const isReplacingReceipt = isEditing && hasReceipt ( initialTransaction ) ;
124+ const isReplacingReceipt = ( isEditing && hasReceipt ( initialTransaction ) ) || ( ! ! initialTransaction ?. receipt && ! ! backTo ) ;
125125
126126 const [ optimisticTransactions ] = useOnyx ( ONYXKEYS . COLLECTION . TRANSACTION_DRAFT , {
127127 selector : ( items ) => Object . values ( items ?? { } ) ,
@@ -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 ,
@@ -505,8 +505,14 @@ function IOURequestStepScan({
505505
506506 // If there was no reportID, then that means the user started this flow from the global + menu
507507 // and an optimistic reportID was generated. In that case, the next step is to select the participants for this expense.
508- if ( iouType === CONST . IOU . TYPE . CREATE && isPaidGroupPolicy ( activePolicy ) && activePolicy ?. isPolicyExpenseChatEnabled && ! shouldRestrictUserBillableActions ( activePolicy . id ) ) {
509- 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+ ) {
510516 const setParticipantsPromises = files . map ( ( receiptFile ) => setMoneyRequestParticipantsFromReport ( receiptFile . transactionID , activePolicyExpenseChat ) ) ;
511517 Promise . all ( setParticipantsPromises ) . then ( ( ) =>
512518 Navigation . navigate (
@@ -519,6 +525,12 @@ function IOURequestStepScan({
519525 ) ,
520526 ) ;
521527 } 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+ }
522534 navigateToParticipantPage ( iouType , initialTransactionID , reportID ) ;
523535 }
524536 } ,
@@ -527,6 +539,9 @@ function IOURequestStepScan({
527539 report ,
528540 reportNameValuePairs ,
529541 iouType ,
542+ initialTransaction ?. participants ,
543+ initialTransaction ?. currency ,
544+ initialTransaction ?. reportID ,
530545 activePolicy ,
531546 initialTransactionID ,
532547 navigateToConfirmationPage ,
@@ -536,7 +551,6 @@ function IOURequestStepScan({
536551 currentUserPersonalDetails ?. login ,
537552 currentUserPersonalDetails . accountID ,
538553 reportID ,
539- initialTransaction ?. currency ,
540554 transactionTaxCode ,
541555 transactionTaxAmount ,
542556 policy ,
@@ -573,7 +587,7 @@ function IOURequestStepScan({
573587 files . forEach ( ( file , index ) => {
574588 const source = URL . createObjectURL ( file as Blob ) ;
575589 const transaction =
576- ! isBetaEnabled ( CONST . BETAS . NEWDOT_MULTI_FILES_DRAG_AND_DROP ) || ( index === 0 && transactions . length === 1 && ! initialTransaction ?. receipt )
590+ ! shouldAcceptMultipleFiles || ( index === 0 && transactions . length === 1 && ! initialTransaction ?. receipt ?. source )
577591 ? ( initialTransaction as Partial < Transaction > )
578592 : buildOptimisticTransactionAndCreateDraft ( {
579593 initialTransaction : initialTransaction as Partial < Transaction > ,
0 commit comments