diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index e9303a355349..2b3bc8380e87 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -140,6 +140,9 @@ function IOURequestStepScan({ selector: transactionDraftValuesSelector, canBeMissing: true, }); + + const shouldPreventPhotoCapture = useRef(false); + const transactions = useMemo(() => { const allTransactions = optimisticTransactions && optimisticTransactions.length > 1 ? optimisticTransactions : [initialTransaction]; return allTransactions.filter((transaction): transaction is Transaction => !!transaction); @@ -789,7 +792,20 @@ function IOURequestStepScan({ }); }, []); + useEffect(() => { + if (!isTabActive) { + return; + } + shouldPreventPhotoCapture.current = false; + }, [isTabActive]); + const capturePhoto = useCallback(() => { + if (shouldPreventPhotoCapture.current) { + return; + } + if (!isMultiScanEnabled) { + shouldPreventPhotoCapture.current = true; + } if (trackRef.current && isFlashLightOn) { trackRef.current .applyConstraints({ @@ -805,7 +821,7 @@ function IOURequestStepScan({ } getScreenshot(); - }, [isFlashLightOn, getScreenshot, clearTorchConstraints]); + }, [isFlashLightOn, getScreenshot, clearTorchConstraints, isMultiScanEnabled]); const panResponder = useRef( PanResponder.create({