Skip to content

Treat an unfolded foldable phone as a tablet in native landscape detection - #108221

Draft
GCyganek wants to merge 24 commits into
Expensify:mainfrom
software-mansion-labs:@GCyganek/fix-native-landscape-detection-unfolded-duo
Draft

GCyganek wants to merge 24 commits into
Expensify:mainfrom
software-mansion-labs:@GCyganek/fix-native-landscape-detection-unfolded-duo

Conversation

@GCyganek

@GCyganek GCyganek commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

This PR makes the app usable on an unfolded iPhone Duo, whose inner display is a tablet-sized window on a device that reports itself as a phone. Most of the changes apply to every tablet-sized native window (unfolded Duo, iPad, Android tablet). The camera changes apply only to the Duo's inner display.

1. Landscape detection (#106376, #106385)

On native, isInLandscapeMode only excluded devices that report as tablets, so an unfolded Duo held sideways got the layout meant for a short phone window. That layout caps heights, which caused the Save button in the middle of Split (#106376) and the suggestion list showing two emojis per scroll (#106385). isInLandscapeMode now also returns false when the window's short side is at least TABLET_MIN_SCREEN_DIMENSION (600, now shared with web isTablet via isTabletSizedWindow). The window is read on every call, so folding the phone brings the landscape layout back.

2. Camera on the Duo's inner display (#106375)

The inner display is mounted a quarter turn from the camera, which caused two problems:

The preview and photos were turned 90°. VisionCamera rotates the camera output based on the screen's orientation, which assumes the screen is aligned with the camera. This is fixed with a VisionCamera patch taken from the upstream fix (margelo/react-native-vision-camera#4251). Devices whose screen is aligned with the camera are unaffected. The patch can be dropped once the fix is released.

The viewfinder didn't match the photo. On the inner display, a photo is wide when the phone is held upright and tall when it's held sideways, the opposite of the screen. Our viewfinder takes its shape from the screen, so it showed a different crop than the photo it saved. VisionCamera doesn't tell the app which rotation it applied, so on the unfolded Duo (isDisplayRotatedFromCamera: a phone with a tablet-sized window) we flip the viewfinder's shape and fit it inside the camera area. useReceiptPhotoOutput now works out the photo's shape from the window instead of taking isInLandscapeMode: since an unfolded foldable phone no longer uses the landscape layout (section 1), the layout can't tell that it takes a wide photo in a wide window. Phones and tablets keep the viewfinder they had before. Once VisionCamera reports the rotation, this special case can be replaced.

The camera screens keep their own landscape check. Scan, Odometer and the attachment camera read useShouldUseCameraLandscapeLayout instead of useIsInLandscapeMode. It is the check from main (a phone with a window wider than tall) and leaves out only the unfolded Duo. That way the change in section 1 doesn't reach the camera.

3. Modals and headers in tablet-sized native windows

On native, the layout is always narrow, so these windows got phone UI stretched across a much wider window.

  • Bottom-docked modals (popover menus, confirm modals, prompts) show as a card up to 640pt wide, centered and rising from the bottom edge, when the window is wider than tall and wider than the mobile breakpoint (shouldShowBottomDockedModalAsCard). Held upright, they stay full-width sheets as on a phone. The card skips the side safe-area padding, because it doesn't reach the window's edges.
  • ReanimatedModal container: for bottom-docked modals only, its animated wrapper now has pointerEvents="box-none". A tap beside the card then reaches the backdrop and closes the modal, as a tap above it already did. On a phone the wrapper is exactly as wide as the sheet, so nothing changes there. Other modal types keep the wrapper catching taps, so their outside-tap behavior is unchanged.
  • Feature training modals were broken (multi-scan, hold and hold/reject education). In a tablet-sized window they used the centered modal type, which on native is a phone-style full-screen page. The content ended up stuck in the top-left corner, with a white band across the rest of the top and the screen below left undimmed. They now use the bottom-docked type: the card described above when held sideways, and a full-width sheet with the content spanning the window when held upright (useHasFixedWidth).
  • Header buttons stay in the header row in tablet-sized windows (useShouldDisplayButtonsInSeparateLine/index.native.ts), since there is room next to the title. This includes the expense report header (MoneyReportHeader, MoneyReportHeaderActions), which now reads the same hook. On an iPad and an Android tablet, the buttons used to sit on a separate line in both orientations.
  • Emoji picker: the list and its category headers took the window's width, so they overflowed the card. They now take the width of the modal they sit in: the card's 640pt, or the window minus its side safe area for a sheet. The width is worked out rather than measured, because the modal shrinks to fit its content, so a measured width would keep the picker a card after rotating to portrait.
  • Multi-scan education illustration: it's sized by the art's aspect ratio (375/220) instead of a fixed 220pt height. With a fixed height it was cropped on any window wider than 375pt (already slightly on Pro Max phones).

Fixed Issues

$ #106376
$ #106375
$ #106385
PROPOSAL: N/A

Tests

Preconditions:

  • An iPhone Duo. A simulator works for every test except Camera, which needs a physical Duo.
  • An account with a workspace that has at least one expense, and a chat with another user.

Test 1: Split Save button (#106376)

  1. Unfold the Duo and hold it sideways, then launch the app.
  2. Go to a workspace chat and create an expense.
  3. Open the expense.
  4. Tap More → Split.
  5. Verify the Save button is at the bottom of the page, with no blank space below it.
  6. Fold the Duo (cover display) and hold it sideways.
  7. Verify the Split page uses the phone landscape layout, as on main.

Test 2: Emoji suggestions (#106385)

  1. Unfold the Duo and hold it sideways, then launch the app.
  2. Open any chat.
  3. Type :sm in the composer.
  4. Verify the suggestion list shows 5 emojis per scroll, not 2.
  5. Fold the Duo (cover display) and hold it sideways.
  6. Verify the suggestion list uses the phone landscape layout, as on main.

Test 3: Bottom-docked modals

  1. Unfold the Duo and hold it sideways.
  2. Tap + (actions menu).
  3. Verify the menu shows as a centered card, up to 640pt wide, rising from the bottom edge.
  4. Tap beside the card (left or right of it).
  5. Verify the menu closes.
  6. Open an expense → More → Delete.
  7. Verify the confirm modal shows as a centered card.
  8. Dismiss the modal and rotate the Duo upright.
  9. Tap +.
  10. Verify the menu is a full-width sheet, as on a phone.

Test 4: Emoji picker

  1. Unfold the Duo and hold it sideways.
  2. Open a chat and tap the emoji icon in the composer.
  3. Verify the emoji grid and the category headers fit inside the card, with no clipped or overflowing columns.
  4. With the picker still open, rotate the Duo upright.
  5. Verify the picker becomes a full-width sheet and the grid fills its width.

Test 5: Header buttons

  1. Unfold the Duo and hold it sideways.
  2. Open a workspace → Categories.
  3. Verify "Add category" and "More" sit in the header row next to the title, not on a separate line.
  4. Rotate the Duo upright.
  5. Verify "Add category" and "More" stay in the header row.
  6. Open an expense report, held sideways and then upright.
  7. Verify the primary action (e.g. "Submit") and "More" sit at the right end of the next-step row ("Waiting for you to submit expenses.") under the title in both orientations, not on a full-width line of their own.

Test 6: Multi-scan education modal
Precondition: an account that has never seen the multi-scan education modal.

  1. Unfold the Duo and hold it sideways.
  2. Open Create expense → Scan.
  3. Turn on multi-scan.
  4. Verify the education modal is a bottom-docked card that shows the whole illustration, with the screen behind it dimmed.
  5. With the modal still open, rotate the Duo upright.
  6. Verify the modal becomes a full-width sheet with its content spanning the width.

Test 7: Camera (physical Duo only)

  1. Unfold the Duo and hold it upright.
  2. Open Create expense → Scan.
  3. Verify the preview is upright and the viewfinder is wide (landscape-shaped) and centered.
  4. Take a photo.
  5. Verify the saved receipt shows the same view as the viewfinder.
  6. Go back to Scan and hold the Duo sideways.
  7. Verify the viewfinder is tall (portrait-shaped) and centered, and the shutter, flash and gallery buttons are in a row below it, not beside it.
  8. Take a photo.
  9. Verify the saved receipt shows the same view as the viewfinder.
  10. Go back to Scan, turn on multi-scan and take a photo upright and another sideways.
  11. Verify the viewfinder is wide upright, tall sideways, and each photo matches its viewfinder.
  12. Open Track distance → Odometer → camera icon, held upright and then sideways.
  13. Verify the viewfinder is wide upright, tall sideways, and the photo matches it.
  14. Open a chat → Attach → Take photo, held upright and then sideways.
  15. Verify the viewfinder is wide upright, tall sideways, and the photo matches it.
  16. Fold the Duo and hold it upright.
  17. Open Create expense → Scan and take a photo.
  18. Verify the camera behaves as on any iPhone.
  19. Hold the folded Duo sideways.
  20. Verify the controls are beside the preview, as on any iPhone held sideways.
  21. With Scan still open, hold the Duo upright and unfold it.
  22. Verify the preview is upright and the viewfinder is wide and centered.
  23. Fold the Duo again.
  24. Verify the preview stays upright and the viewfinder fills the screen, as on any iPhone.

Test 8: Regular iPhone regression

  1. On a regular iPhone held upright, tap +.
  2. Verify the menu is a full-width sheet.
  3. Rotate the phone sideways and tap +.
  4. Verify the menu is still a full-width sheet.
  5. Open a workspace → Categories.
  6. Verify the header looks as on main.
  7. Hold the phone sideways, open a chat and tap the emoji icon in the composer.
  8. Verify the emoji grid and the category headers fit inside the sheet.
  9. Open an expense report, held upright and then sideways.
  10. Verify the header buttons are on a separate line upright and in the header row sideways, as on main.
  11. With an account that has never seen the multi-scan education modal, open Scan and turn on multi-scan.
  12. Verify the education modal is a full-width sheet that shows the whole illustration.

Test 9: iPad

  1. Hold the iPad sideways.
  2. Tap +.
  3. Verify the menu shows as a centered card rising from the bottom edge.
  4. Tap beside the card.
  5. Verify the menu closes.
  6. Open a chat and tap the emoji icon in the composer.
  7. Verify the emoji grid fits inside the card.
  8. With the picker still open, rotate the iPad upright.
  9. Verify the picker becomes a full-width sheet and the grid fills its width.
  10. Open a workspace → Categories, held sideways and then upright.
  11. Verify "Add category" and "More" sit in the header row next to the title in both orientations.
  12. Open an expense report, held sideways and then upright.
  13. Verify the primary action (e.g. "Submit") and "More" sit at the right end of the next-step row ("Waiting for you to submit expenses.") under the title in both orientations, not on a full-width line of their own.
  14. With an account that has never seen the multi-scan education modal, open Create expense → Scan and turn on multi-scan.
  15. Verify the education modal is a bottom-docked card held sideways and a full-width sheet held upright, with the whole illustration shown

Test 10: Android tablet and foldable

  1. On an Android tablet emulator held sideways, tap +.
  2. Verify the menu shows as a centered card rising from the bottom edge, and a tap beside it closes it.
  3. Open a chat and tap the emoji icon in the composer.
  4. Verify the emoji grid fits inside the card.
  5. Open a workspace → Categories.
  6. Verify "Add category" and "More" sit in the header row next to the title.
  7. On an Android foldable emulator, launch the app folded, then unfold it and hold it sideways.
  8. Open an expense → More → Split.
  9. Verify the Save button is at the bottom of the page, with no blank space below it.
  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@GCyganek

Copy link
Copy Markdown
Contributor Author

@codex please review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T15:53:21.820389Z 90909cc Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 453d0bdc93

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@GCyganek

Copy link
Copy Markdown
Contributor Author

I need to test this one using real iphone duo so I will do it on Monday

@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
...c/components/AttachmentPicker/AttachmentCamera.tsx 88.30% <100.00%> (+0.06%) ⬆️
...mponents/FeatureTraining/hooks/useHasFixedWidth.ts 100.00% <100.00%> (ø)
...ents/FeatureTraining/hooks/useScrollableWrapper.ts 97.36% <100.00%> (+0.07%) ⬆️
...components/FeatureTraining/primitives/BodyText.tsx 100.00% <100.00%> (ø)
...onents/FeatureTraining/primitives/Illustration.tsx 85.71% <100.00%> (+0.25%) ⬆️
src/components/FeatureTrainingModal.tsx 96.66% <100.00%> (+0.11%) ⬆️
src/components/Modal/BaseModal.tsx 98.77% <100.00%> (+<0.01%) ⬆️
...mponents/Modal/ReanimatedModal/Container/index.tsx 100.00% <100.00%> (ø)
src/components/MoneyReportHeader.tsx 98.94% <100.00%> (+0.01%) ⬆️
src/components/MoneyReportHeaderActions/index.tsx 93.33% <100.00%> (+0.11%) ⬆️
... and 20 more
... and 30 files with indirect coverage changes

VisionCamera rotates every output by the interface orientation alone, so the camera is turned 90 degrees on the iPhone Duo's inner display. The patch is the upstream fix from margelo/react-native-vision-camera#4251.
On the iPhone Duo's inner display the photo's shape doesn't follow the UI orientation, so a photo-shaped viewfinder crops the preview. In a tablet-sized window the viewfinder now fills its area, the preview fits the whole frame in it, and the odometer photo is no longer cropped to the viewfinder.
The list and its category headers took the window's width, so in the card a tablet-sized window shows the last two emoji columns were cut off.
9.0.4 adds the ancestor's safe area on top of the inherited one, so tab content in Create expense is cut short on the iPhone Duo. Same change as Expensify#108303.
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@GCyganek

Copy link
Copy Markdown
Contributor Author

@Expensify/design to fix a few issues I updated logic to not treat unfolded landscape iPhone duo as landscape mode on normal phones where vertical space is limited. Because of this iPhone Duo unfolded landscape works similar to iPad landscape mode now, but there are a few things I want you to check and let me know if they're ok:

  • scan expense camera preview & output (also the same layout in both landscape and portrait here):
ScreenRecording_11-30-2026.17.mov
  • modals are centered in unfolded landscape (will also look like this on ios and android tablets, let me know if its ok):
modal-feature-training-multiscan modal-emoji-picker modal-attachment-picker-menu modal-confirm-delete-comment
  • onboarding flow looks like on tablets on iphone duo unfolded landscape:
Screenshot 2026-11-30 at 11 09 58
  • portrait bottom modals still full width
modal-feature-training-multiscan

@dubielzyk-expensify

dubielzyk-expensify commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Yeah that's feeling A LOT better!

Onboarding missing the scrim, is that a separate bug?

The only thing I think would be worth improving is that all illustrations get cut off cause it doesn't follow the aspect ratio. I guess we could:

  1. ensure the max-width is the same as desktop
  2. scale the illustration container with the aspect ratio
  3. do nothing

I'm curious what @Expensify/design think here. I'm hesitant to invest loooads of time in this for now and wonder if we should do 3 until we decide it's worth it later. I think 1 would potentially be a tad weird for the Duo and other foldables, but not against that either. 2 is probably not worth it.

Curious for your take too @GCyganek and if there's other things that comes to mind for you

@GCyganek

GCyganek commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Onboarding missing the scrim, is that a separate bug?

From what I recall, that’s how it works on tablets in landscape mode, but I can check if there can be something done with it

…olded-duo

# Conflicts:
#	src/pages/iou/request/step/IOURequestStepScan/components/Camera/index.native.tsx
@dubielzyk-expensify

Copy link
Copy Markdown
Contributor

Cool. Definitely wanna fix it as a follow-up for whatever is going on there since it looks broken atm

@GCyganek

GCyganek commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Also it looks like only multi-scan is using fixed height, so switching it to aspect ratio should fix the problem, but I'm checking other illustrations as well

@GCyganek

GCyganek commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author
Screenshot 2026-12-01 at 09 40 58 Screenshot 2026-12-01 at 09 41 05 Screenshot 2026-12-01 at 09 43 34

@dubielzyk-expensify

Copy link
Copy Markdown
Contributor

You a machine! That looks great

@GCyganek

GCyganek commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, I will fix the onboarding screen backdrop in a follow-up to not make this PR too big. I will test everything again and make sure I did not break anything on iOS/Android tablets and then switch this PR to review

@shawnborton

Copy link
Copy Markdown
Contributor

Nice, looking good! And totally agree that we need to fix the onboarding flow.

@GCyganek

GCyganek commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@codex please review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e645b2ed0a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread src/hooks/useReceiptPhotoOutput.ts Resolved
@GCyganek

GCyganek commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

I will try to finally switch this PR to review tomorrow morning as I was busy today with fixing new deploy blockers

@GCyganek

GCyganek commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

@codex please review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 90909ccaaf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants