Skip to content

Commit ca1f4ff

Browse files
authored
Merge pull request #57707 from nkdengineer/fix/56752
fix: Deeplinking expense creation leads to an expense with 0 amount
2 parents 10195c1 + 7f57b78 commit ca1f4ff

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/pages/iou/request/step/IOURequestStepConfirmation.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,29 @@ function IOURequestStepConfirmation({
201201
}, [transactionID, defaultBillable]);
202202

203203
useEffect(() => {
204-
if (!!isLoadingTransaction || (transaction?.transactionID && (!transaction?.isFromGlobalCreate || !isEmptyObject(transaction?.participants)))) {
204+
// Exit early if the transaction is still loading
205+
if (isLoadingTransaction) {
205206
return;
206207
}
208+
209+
// Check if the transaction belongs to the current report
210+
const isCurrentReportID = transaction?.isFromGlobalCreate
211+
? transaction?.participants?.at(0)?.reportID === reportID || (!transaction?.participants?.at(0)?.reportID && transaction?.reportID === reportID)
212+
: transaction?.reportID === reportID;
213+
214+
// Exit if the transaction already exists and is associated with the current report
215+
if (transaction?.transactionID && (!transaction?.isFromGlobalCreate || !isEmptyObject(transaction?.participants)) && isCurrentReportID) {
216+
return;
217+
}
218+
207219
startMoneyRequest(
208220
CONST.IOU.TYPE.CREATE,
209221
// When starting to create an expense from the global FAB, there is not an existing report yet. A random optimistic reportID is generated and used
210222
// for all of the routes in the creation flow.
211223
generateReportID(),
212224
);
213225
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps -- we don't want this effect to run again
214-
}, [isLoadingTransaction]);
226+
}, [isLoadingTransaction, reportID]);
215227

216228
useEffect(() => {
217229
if (!transaction?.category) {

0 commit comments

Comments
 (0)