diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 744f3f4c575b..a16ebe8d7cb5 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -92,9 +92,10 @@ Onyx.connect({ /** * Initialize money request info * @param {String} reportID to attach the transaction to + * @param {Boolean} isFromGlobalCreate * @param {String} [iouRequestType] one of manual/scan/distance */ -function startMoneyRequest_temporaryForRefactor(reportID, iouRequestType = CONST.IOU.REQUEST_TYPE.MANUAL) { +function startMoneyRequest_temporaryForRefactor(reportID, isFromGlobalCreate, iouRequestType = CONST.IOU.REQUEST_TYPE.MANUAL) { // Generate a brand new transactionID const newTransactionID = CONST.IOU.OPTIMISTIC_TRANSACTION_ID; const created = currentDate || format(new Date(), 'yyyy-MM-dd'); @@ -118,6 +119,7 @@ function startMoneyRequest_temporaryForRefactor(reportID, iouRequestType = CONST iouRequestType, reportID, transactionID: newTransactionID, + isFromGlobalCreate, }); } diff --git a/src/pages/iou/request/IOURequestStartPage.js b/src/pages/iou/request/IOURequestStartPage.js index 8c0f00af95e0..48efc0bdd17c 100644 --- a/src/pages/iou/request/IOURequestStartPage.js +++ b/src/pages/iou/request/IOURequestStartPage.js @@ -68,6 +68,7 @@ function IOURequestStartPage({ }; const transactionRequestType = useRef(TransactionUtils.getRequestType(transaction)); const previousIOURequestType = usePrevious(transactionRequestType.current); + const isFromGlobalCreate = _.isEmpty(report.reportID); // Clear out the temporary money request when this component is unmounted useEffect( @@ -82,10 +83,9 @@ function IOURequestStartPage({ if (transaction.reportID === reportID) { return; } - IOU.startMoneyRequest_temporaryForRefactor(reportID, transactionRequestType.current); - }, [transaction, reportID, iouType]); + IOU.startMoneyRequest_temporaryForRefactor(reportID, isFromGlobalCreate, transactionRequestType.current); + }, [transaction, reportID, iouType, isFromGlobalCreate]); - const isFromGlobalCreate = _.isEmpty(report.reportID); const isExpenseChat = ReportUtils.isPolicyExpenseChat(report); const isExpenseReport = ReportUtils.isExpenseReport(report); const shouldDisplayDistanceRequest = isExpenseChat || isExpenseReport || isFromGlobalCreate; @@ -102,10 +102,10 @@ function IOURequestStartPage({ if (newIouType === previousIOURequestType) { return; } - IOU.startMoneyRequest_temporaryForRefactor(reportID, newIouType); + IOU.startMoneyRequest_temporaryForRefactor(reportID, isFromGlobalCreate, newIouType); transactionRequestType.current = newIouType; }, - [previousIOURequestType, reportID], + [previousIOURequestType, reportID, isFromGlobalCreate], ); return ( diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index 81c153cb2320..55ed2ebae543 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -192,14 +192,14 @@ function IOURequestStepConfirmation({ // If we have a receipt let's start the split bill by creating only the action, the transaction, and the group DM if needed if (iouType === CONST.IOU.TYPE.SPLIT && receiptFile) { - const existingSplitChatReportID = CONST.REGEX.NUMBER.test(reportID) ? reportID : ''; + const existingSplitChatReportID = CONST.REGEX.NUMBER.test(report.reportID) ? reportID : ''; IOU.startSplitBill(selectedParticipants, currentUserPersonalDetails.login, currentUserPersonalDetails.accountID, trimmedComment, receiptFile, existingSplitChatReportID); return; } // IOUs created from a group report will have a reportID param in the route. // Since the user is already viewing the report, we don't need to navigate them to the report - if (iouType === CONST.IOU.TYPE.SPLIT && CONST.REGEX.NUMBER.test(reportID)) { + if (iouType === CONST.IOU.TYPE.SPLIT && !transaction.isFromGlobalCreate) { IOU.splitBill( selectedParticipants, currentUserPersonalDetails.login,