refactor: IOURequestStepScan clean-up, phase 6: move multi-scan state to hook and use key for reset#86800
refactor: IOURequestStepScan clean-up, phase 6: move multi-scan state to hook and use key for reset#86800samranahm wants to merge 14 commits intoExpensify:mainfrom
IOURequestStepScan clean-up, phase 6: move multi-scan state to hook and use key for reset#86800Conversation
|
@bernhardoj Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
There was a problem hiding this comment.
Pull request overview
Refactors the money request Scan step (IOURequestStepScan) to reduce prop-driven state by moving multi-scan/scan-mode state into useReceiptScan, and resets Scan step state via a React key from the start page.
Changes:
- Move
isMultiScanEnabledandisStartingScanstate/derivation intouseReceiptScanand remove the related props from Scan step components. - Update web + native Scan step implementations and shared types to match the new hook-driven API.
- Update unit/UI tests to interact with the new internal multi-scan state (via hook setters) and remove now-deleted props.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/hooks/useReceiptScan.test.ts | Updates tests to toggle multi-scan via the hook’s setter instead of rerendering with props; adjusts “starting scan” semantics. |
| tests/ui/IOURequestStepScanTest.tsx | Removes multi-scan props and adds an additional draft transaction to cover multi-draft scenarios. |
| src/pages/iou/request/step/IOURequestStepScan/types.ts | Removes multi-scan/starting-scan from UseReceiptScanParams; makes isStartingScan and setIsMultiScanEnabled required for mobile hook usage. |
| src/pages/iou/request/step/IOURequestStepScan/index.tsx | Web Scan step now consumes isMultiScanEnabled/setIsMultiScanEnabled/isStartingScan from useReceiptScan and passes them down. |
| src/pages/iou/request/step/IOURequestStepScan/index.native.tsx | Native Scan step now consumes multi-scan + starting-scan state from useReceiptScan and wires it into useMobileReceiptScan. |
| src/pages/iou/request/step/IOURequestStepScan/hooks/useReceiptScan.ts | Introduces internal multi-scan state + derives isStartingScan from action; returns these values to callers. |
| src/pages/iou/request/step/IOURequestStepScan/hooks/useMobileReceiptScan.ts | Makes isStartingScan required and setIsMultiScanEnabled non-optional; removes optional chaining on setter usage. |
| src/pages/iou/request/step/IOURequestStepScan/components/MobileWebCameraView.tsx | Tightens prop types to require isStartingScan and setIsMultiScanEnabled; keeps isMultiScanEnabled defaulting behavior. |
| src/pages/iou/request/IOURequestStartPage.tsx | Removes parent-held multi-scan state and adds a key on IOURequestStepScan intended to reset Scan state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
No product review needed |
src/pages/iou/request/step/IOURequestStepScan/components/MobileWebCameraView.tsx
Show resolved
Hide resolved
|
Please apply this suggestion |
src/pages/iou/request/step/IOURequestStepScan/hooks/useReceiptScan.ts
Outdated
Show resolved
Hide resolved
Implemented the checklist from #82130 (comment) |
|
@bernhardoj PR ready for re-review. |
|
All checks passing, @bernhardoj please take a look. |
src/pages/iou/request/step/IOURequestStepScan/components/MobileWebCameraView.tsx
Outdated
Show resolved
Hide resolved
|
@codex review |
|
@samranahm we are changing the multi-scan code here, so please add test steps for toggling the multi scan or when switching tabs (the other test steps seem unnecessary). Please add recording too. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppandroid.mp4Android: mWeb Chromeandroid.mweb.mp4iOS: HybridAppios.mp4iOS: mWeb Safariios.mweb.mp4MacOS: Chrome / Safariweb.mp4 |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
…ering Co-authored-by: Bernhard Owen Josephus <[email protected]>
|
@bernhardoj All yours. |
src/pages/iou/request/step/IOURequestStepScan/components/MobileWebCameraView.tsx
Outdated
Show resolved
Hide resolved
|
All good, Thanks @bernhardoj for continuous support throughout the project. |
Explanation of Change
Fixed Issues
$ #79929
PROPOSAL:
Tests
Test 01
Offline tests
QA Steps
Same as test
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android.Native.mp4
Android: mWeb Chrome
Android.mWeb.Chrome.mp4
iOS: Native
IOS.Native.mp4
iOS: mWeb Safari
IOS.mWeb.Safari.mp4
MacOS: Chrome / Safari
macOS.Chrome.mp4