Skip to content

Keep Plaid in portrait on Android phones so its inputs stay visible - #105598

Merged
mollfpr merged 5 commits into
Expensify:mainfrom
mukhrr:fix/102562
Nov 6, 2026
Merged

mollfpr merged 5 commits into
Expensify:mainfrom
mukhrr:fix/102562

Conversation

@mukhrr

@mukhrr mukhrr commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

On Android phones we override Plaid's own portrait lock, and in landscape the keyboard leaves Plaid's WebView too short to show its login inputs. The override now applies to tablets only, so phones keep Plaid in portrait and the inputs stay visible.

Fixed Issues

$ #102562
PROPOSAL: #102562 (comment)

Tests

Android phone, account without a wallet bank account.

  1. Go to Account > Wallet and enable the wallet.
  2. Tap Add bank account, choose United States, then Regions Bank.
  3. On the Plaid login page, tap the Online ID field and rotate the device to landscape.
  4. Verify Plaid stays in portrait and the Online ID field is still visible above the keyboard.
  5. Type a few letters and verify they appear in the field with the cursor after the last letter.
  6. Tap back to exit Plaid, rotate the device to landscape, and verify the rest of the app still rotates.
  7. Open Plaid again while the app is in landscape and verify it opens in portrait with no white page.
  8. On an Android tablet, repeat steps 1 to 3 and verify Plaid rotates to landscape.
  • Verify that no errors appear in the JS console

Offline tests

Plaid needs a connection to load, so the flow cannot run offline. The change only sets the orientation of Plaid's activity when it is created and has no network surface.

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 the Expensify/design team 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
102562-android-app.mp4
Android: mWeb Chrome
102562-android-web.mp4
iOS: Native
102562-ios-app.mp4
iOS: mWeb Safari
102562-ios-web.mp4
MacOS: Chrome / Safari
102562-after-web.mp4

@mukhrr
mukhrr requested review from a team as code owners November 2, 2026 08:53
@melvin-bot
melvin-bot Bot requested review from heyjennahay and hoangzinh and removed request for a team November 2, 2026 08:53
@melvin-bot

melvin-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown

@hoangzinh 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]

@melvin-bot
melvin-bot Bot removed the request for review from a team November 2, 2026 08:53
@chatgpt-codex-connector

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T09:07:06.713682Z f15de4b PR opened
ℹ️ 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.

@github-actions

github-actions Bot commented Nov 2, 2026

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. ⚠️

Plaid's LinkActivity locks itself to portrait. We override that to
UNSPECIFIED so Plaid follows the device orientation, but on a phone in
landscape the keyboard leaves Plaid's WebView about 126dp tall, which
Plaid's own header fills, so the login inputs sit under the keyboard.

Apply the override only when smallestScreenWidthDp is 600 or more, the
same tablet threshold DeviceInfo.isTablet() uses on Android. Phones fall
back to Plaid's portrait lock, tablets keep landscape Plaid.

@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: f15de4bf37

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

LinkActivity declares smallestScreenSize in configChanges, so folding or
unfolding across the 600dp threshold while Plaid is open does not recreate
it and onActivityCreated never runs again. Keep a weak reference to the
live LinkActivity and re-apply the orientation from
Application.onConfigurationChanged.

Phones now get an explicit PORTRAIT instead of relying on Plaid's own
lock, so a session opened unfolded locks when the device is folded.
Android 8.0 is skipped because a translucent activity cannot request a
fixed orientation there, which is why Plaid skips it as well.
@mukhrr

mukhrr commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@hoangzinh PR is ready

}
// Android 8.0 throws when a translucent activity requests a fixed orientation; Plaid skips it there too.
if (Build.VERSION.SDK_INT != Build.VERSION_CODES.O) {
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@mukhrr why don't we use Plaid's requestedOrientation? (I recall Plaid already set ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hmm yeah, it makes sense to me

Comment on lines +80 to +84
override fun onActivityDestroyed(activity: Activity) {
if (plaidLinkActivity?.get() === activity) {
plaidLinkActivity = null
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Those LOC doesn't have in your proposal. Can you explain it a bit here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

these are from Codex comment above and i think it's valid concern. LinkActivity has smallestScreenSize in configChanges, so fold/unfold doesn't recreate it and onActivityCreated won't run again. that's why we keep ref and re-apply in onConfigurationChanged

Plaid sets its orientation before super.onCreate(), so LinkActivity already holds Plaid's value when onActivityCreated runs. Save it there and restore it below 600dp instead of hardcoding portrait and duplicating Plaid's API 26 check.
@mukhrr
mukhrr requested a review from hoangzinh November 3, 2026 12:37

private fun applyPlaidOrientation(activity: Activity, config: Configuration) {
activity.requestedOrientation =
if (config.smallestScreenWidthDp >= 600) ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED else plaidRequestedOrientation

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we do nothing in the else clause? @mukhrr

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@hoangzinh no, I think it's needed for the fold case. on first open it's no-op, value is already Plaid's. but if user unfolds (we set UNSPECIFIED) and then folds back, without else it stays UNSPECIFIED and we get original bug again on phone

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@mukhrr I got this AI review on hybrid repo

On Android 16+ (Android/build.gradle:226 targets SDK 36), when LinkActivity is first created in an sw600dp+ window, the platform ignores Plaid's portrait request and getRequestedOrientation() is normalized to SCREEN_ORIENTATION_UNSPECIFIED. If an unfolded foldable is then folded below 600dp, LinkActivity is not recreated because Android/AndroidManifest.xml:277 handles smallestScreenSize, so this branch reapplies UNSPECIFIED; Plaid remains rotatable in the phone-sized window and the landscape-keyboard regression returns. The small-screen branch should request portrait explicitly rather than replaying the value captured while the request was ignored.

It seems we need to revert to your original version.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree with the review. I’ll hold the merge until we have a follow-up for it.

@mukhrr
mukhrr requested a review from hoangzinh November 5, 2026 05:51
@hoangzinh

Copy link
Copy Markdown
Contributor

Opening PR in Hybrid repo

@hoangzinh

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • 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 verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Screen.Recording.2026-11-05.at.21.13.09.mov
Android: mWeb Chrome
iOS: HybridApp
Screen.Recording.2026-11-05.at.21.33.22.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-11-05.at.21.26.40.mov

@hoangzinh hoangzinh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚢

@melvin-bot
melvin-bot Bot requested a review from mollfpr November 5, 2026 14:41
@hoangzinh

Copy link
Copy Markdown
Contributor

mollfpr
mollfpr previously approved these changes Nov 6, 2026

@mollfpr mollfpr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me! Thanks!

@mollfpr
mollfpr self-requested a review November 6, 2026 03:03
@mukhrr

mukhrr commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

@mollfpr I thnk we are good to merge now. thanks

@mollfpr mollfpr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thanks!

@mollfpr
mollfpr merged commit 15cb03d into Expensify:main Nov 6, 2026
21 of 22 checks passed
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

🚧 mollfpr has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

OSBotify commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

@OSBotify OSBotify mentioned this pull request Nov 7, 2026
85 tasks done
@OSBotify

OSBotify commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mollfpr in version: 9.5.34-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@jponikarchuk

Copy link
Copy Markdown

This PR failing because of the issue #106342
This issue is reproducible in: Android app

@mukhrr

mukhrr commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

This PR failing because of the issue #106342 This issue is reproducible in: Android app

@hoangzinh is hybrid app PR https://github.com/Expensify/Mobile-Expensify/pull/14216 merged yet?

@hoangzinh

Copy link
Copy Markdown
Contributor

ah nope. @mollfpr could you help to review and merge that hybrid PR?

@OSBotify

OSBotify commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.5.34-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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.

5 participants