From ca8d71814ac2da88cbf3150a10eecc890bcc6fba Mon Sep 17 00:00:00 2001 From: dominictb Date: Thu, 11 Jul 2024 15:12:42 +0700 Subject: [PATCH] fix: do not convert distance in case API call is not finished Signed-off-by: dominictb --- src/components/MoneyRequestConfirmationList.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 2b82042ca3e2..09af8e59621e 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -257,11 +257,11 @@ function MoneyRequestConfirmationList({ const distance = useMemo(() => { const value = TransactionUtils.getDistance(transaction); - if (isMovingTransactionFromTrackExpense && unit) { + if (canUseP2PDistanceRequests && isMovingTransactionFromTrackExpense && unit && !TransactionUtils.isFetchingWaypointsFromServer(transaction)) { return DistanceRequestUtils.convertToDistanceInMeters(value, unit); } return value; - }, [isMovingTransactionFromTrackExpense, unit, transaction]); + }, [isMovingTransactionFromTrackExpense, unit, transaction, canUseP2PDistanceRequests]); const prevDistance = usePrevious(distance); const shouldCalculateDistanceAmount = isDistanceRequest && (iouAmount === 0 || prevRate !== rate || prevDistance !== distance);