From e2b50fb9820d2f5d9300bbc85cc6b15f22c8b973 Mon Sep 17 00:00:00 2001 From: dominictb Date: Fri, 19 Jul 2024 17:04:18 +0700 Subject: [PATCH 1/4] fix: add receipt name when track expense Signed-off-by: dominictb --- src/pages/iou/request/step/IOURequestStepConfirmation.tsx | 3 ++- src/pages/iou/request/step/IOURequestStepScan/index.native.tsx | 2 ++ src/pages/iou/request/step/IOURequestStepScan/index.tsx | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index af808f4a3040..59b809e14ee9 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -278,7 +278,8 @@ function IOURequestStepConfirmation({ currentUserPersonalDetails.accountID, selectedParticipants[0], trimmedComment, - receiptObj, + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + {...receiptObj, name: receiptObj?.name || transaction.filename}, transaction.category, transaction.tag, transactionTaxCode, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 2584a6677ff0..1c0a070e040f 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -243,6 +243,8 @@ function IOURequestStepScan({ const receipt: Receipt = file; receipt.source = source; receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; + receipt.name = file.name; + if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.startSplitBill({ participants, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 44e4819eae4b..ff7131a402f1 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -287,6 +287,8 @@ function IOURequestStepScan({ const receipt: Receipt = file; receipt.source = source; receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; + receipt.name = file.name; + if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.startSplitBill({ participants, From d3546c6e7f82dac917b70b395f035e5881984918 Mon Sep 17 00:00:00 2001 From: dominictb Date: Thu, 25 Jul 2024 18:05:18 +0700 Subject: [PATCH 2/4] fix: clean up implementation --- src/pages/iou/request/step/IOURequestStepConfirmation.tsx | 5 +++-- .../iou/request/step/IOURequestStepScan/index.native.tsx | 1 - src/pages/iou/request/step/IOURequestStepScan/index.tsx | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 9b086c029d6f..d68cd9a445a9 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -275,6 +275,8 @@ function IOURequestStepConfirmation({ if (!report || !transaction) { return; } + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + const receiptObjWithFilename = {...receiptObj, name: receiptObj?.name || transaction.filename}; IOU.trackExpense( report, transaction.amount, @@ -285,8 +287,7 @@ function IOURequestStepConfirmation({ currentUserPersonalDetails.accountID, selectedParticipants[0], trimmedComment, - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - {...receiptObj, name: receiptObj?.name || transaction.filename}, + receiptObjWithFilename, transaction.category, transaction.tag, transactionTaxCode, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 0bddccee4b14..ce1ce21890e9 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -247,7 +247,6 @@ function IOURequestStepScan({ const receipt: Receipt = file; receipt.source = source; receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; - receipt.name = file.name; if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.startSplitBill({ diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index b0f369a0687c..2681aa12c92b 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -279,7 +279,6 @@ function IOURequestStepScan({ const receipt: Receipt = file; receipt.source = source; receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; - receipt.name = file.name; if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.startSplitBill({ From e896d52a31012b66a6ce880b63492e805bdcfeb5 Mon Sep 17 00:00:00 2001 From: dominictb Date: Thu, 1 Aug 2024 09:14:00 +0700 Subject: [PATCH 3/4] fix: remove extra lines --- src/pages/iou/request/step/IOURequestStepScan/index.native.tsx | 1 - src/pages/iou/request/step/IOURequestStepScan/index.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index ce1ce21890e9..8fdecbacb75b 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -247,7 +247,6 @@ function IOURequestStepScan({ const receipt: Receipt = file; receipt.source = source; receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; - if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.startSplitBill({ participants, diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 2681aa12c92b..61e04b4483ed 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -279,7 +279,6 @@ function IOURequestStepScan({ const receipt: Receipt = file; receipt.source = source; receipt.state = CONST.IOU.RECEIPT_STATE.SCANREADY; - if (iouType === CONST.IOU.TYPE.SPLIT) { IOU.startSplitBill({ participants, From 12fb7e6b26a3cedcc0baab836698123f1691478a Mon Sep 17 00:00:00 2001 From: dominictb Date: Thu, 1 Aug 2024 09:21:18 +0700 Subject: [PATCH 4/4] fix: update implementation to remove eslint hack --- src/pages/iou/request/step/IOURequestStepConfirmation.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index d68cd9a445a9..2574b6a848ee 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -275,8 +275,10 @@ function IOURequestStepConfirmation({ if (!report || !transaction) { return; } - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const receiptObjWithFilename = {...receiptObj, name: receiptObj?.name || transaction.filename}; + const receiptObjWithFilename = receiptObj && {...receiptObj}; + if (receiptObjWithFilename && !receiptObjWithFilename?.name) { + receiptObjWithFilename.name = transaction.filename; + } IOU.trackExpense( report, transaction.amount,