Skip to content

[payment due 12-17][$250] Android - Expense - Empty space instead of keyboard if backgrounding app while creating expense #73175

Closed

Description

@jponikarchuk

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.2.36-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/TR-1424/folder/13177029/41237792/965872108
Email or phone of affected tester (no customers): ibellicotest+1942@gmail.com
Issue reported by: Applause Internal Team
Device used: Motorola MotoG60 / Android 12 (Hybrid app)
App Component: Money Requests

Action Performed:

  1. Open the Expensify app.
  2. Open any chat.
  3. Start manual expense creation flow.
  4. Add any amount and tap on "Next"
  5. Open any field to edit. (For example: Merchant)
  6. Open keyboard if it is not opened yet.
  7. With keyboard still opened, background and reopen app.
  8. Note that keyboard is closed, but empty space is displayed below "Save" button. (If this step does not reproduce on first try, repeat step 7 one more time)
  9. Tap on the arrow on the top left corner.
  10. Note that empty space is also visible on details page, below "Create" button.
  11. Tap on the back button on top left corner again, until returning to chat.
  12. Note that the same empty space is visible below composer.
  13. Tap on composer.
  14. Note that keyboard reappears and empty space disappears.

Expected Result:

After backgrounding and reopening app with keyboard opened during expense creation flow, keyboard should close and no empty space should be created on the bottom of the page.

Actual Result:

After backgrounding and reopening app with keyboard opened while editing expense fields during creation, an empty space remains displayed instead of keyboard. This empty space is also visible when returning to previous sections and chat.
Issue only stops reproducing after tapping on composer or text input, to reopen keyboard manually.

Test case #2

  • Launch Expensify app
  • Open any chat
  • Tap emoji button
  • App will not crash

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021981128182593545913
  • Upwork Job ID: 1981128182593545913
  • Last Price Increase: 2025-11-05
  • Automatic offers:
    • dominictb | Reviewer | 109427136

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 22, 2025
  2. melvin-bot commented on Oct 22, 2025

    @melvin-bot

    Triggered auto assignment to @Christinadobrzyn (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. dmkt9 commented on Oct 22, 2025

    @dmkt9
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-11-01 04:11:09 UTC.

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    After backgrounding and reopening app with keyboard opened while editing expense fields during creation, an empty space remains displayed instead of keyboard. This empty space is also visible when returning to previous sections and chat.
    Issue only stops reproducing after tapping on composer or text input, to reopen keyboard manually.

    What is the root cause of that problem?

    1. The MoneyRequestAmountInput component has a disableKeyboard prop that defaults to true. In MoneyRequestAmountForm, this prop isn’t explicitly passed to MoneyRequestAmountInput, so its value remains true:

      disableKeyboard = true,

    2. The disableKeyboard prop is then passed down to TextInput:

      function TextInput({ref, ...props}: BaseTextInputProps) {

    When disableKeyboard === true, we call Keyboard.dismiss when the app transitions to the background. However, since this happens after the app is already in the background, the components can’t update their height after the keyboard is dismissed.

    As a result, when the TextInput is still focused in the following steps, this event still triggers because MoneyRequestAmountInput isn’t actually unmounted, and Keyboard.dismiss is called — which causes the issue.

    What changes do you think we should make in order to solve the problem?

    Only call Keyboard.dismiss when the input's page is currently focused.

    useEffect(() => {
    if (!props.disableKeyboard) {
    return;
    }
    const appStateSubscription = AppState.addEventListener('change', (nextAppState) => {
    if (!nextAppState.match(/inactive|background/)) {
    return;
    }
    Keyboard.dismiss();
    });
    return () => {
    appStateSubscription.remove();
    };
    }, [props.disableKeyboard]);

    +    const navigation = useNavigation();
    
        useEffect(() => {
            if (!props.disableKeyboard) {
                return;
            }
    
            const appStateSubscription = AppState.addEventListener('change', (nextAppState) => {
    -            if (!nextAppState.match(/inactive|background/)) {
    +            if (!nextAppState.match(/inactive|background/) || !navigation.isFocused()) {
                    return;
                }
    
                Keyboard.dismiss();
            });
    
            return () => {
                appStateSubscription.remove();
            };
    -    }, [props.disableKeyboard]);
    +    }, [props.disableKeyboard, navigation]);

    What alternative solutions did you explore? (Optional)

    N/A

    2025-10-22.18-18-43.mp4
  4. Christinadobrzyn commented on Oct 22, 2025

    @Christinadobrzyn
    Contributor

    I can reproduce this with the steps in the OP - adding External

  5. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Oct 22, 2025
  6. melvin-bot commented on Oct 22, 2025

    @melvin-bot
  7. changed the title [-]Android - Expense - Empty space instead of keyboard if backgrounding app while creating expense[/-] [+][$250] Android - Expense - Empty space instead of keyboard if backgrounding app while creating expense[/+] on Oct 22, 2025
  8. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Oct 22, 2025
  9. melvin-bot commented on Oct 22, 2025

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @dominictb (External)

  10. Christinadobrzyn commented on Oct 23, 2025

    @Christinadobrzyn
    Contributor

    Hi @dominictb! Can you please review this proposal? TY

    #73175 (comment)

  11. huult commented on Oct 24, 2025

    @huult
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Empty space instead of keyboard if backgrounding app while creating expense

    What is the root cause of that problem?

    When we navigate to the Description or Merchant page, shouldEnableMaxHeight is set to true.

    shouldEnableMaxHeight={canUseTouchScreen()}

    When shouldEnableMaxHeight is true, the screen limits its height to the current windowHeight.

    const maxHeight = shouldEnableMaxHeight ? windowHeight : undefined;

    After backgrounding the app with the keyboard open and then reopening it, the windowHeight value still reflects the reduced height caused by the (now closed) keyboard.

    As a result, the screen height remains too short, creating extra empty space below the buttons in the expense creation flow.

    What changes do you think we should make in order to solve the problem?

    To fix this issue, we should adjust the max height logic so it’s disabled right after returning from the background if the keyboard isn’t visible.

     useEffect(() => {
            const appStateSubscription = AppState.addEventListener('change', (nextAppState) => {
                if (nextAppState !== 'active') {
                    return;
                }
                // Mark that we returned from background, reset after brief delay
                setHasRecentlyReturnedFromBackground(true);
                setTimeout(() => setHasRecentlyReturnedFromBackground(false), 300);
            });
    
            return () => {
                appStateSubscription.remove();
            };
        }, []);
    
        const shouldEnableMaxHeight = useCallback(() => {
            if (!canUseTouchScreen()) {
                return false;
            }
    
      
            if (hasRecentlyReturnedFromBackground && !Keyboard.isVisible()) {
                return false;
            }
    
            return true;
        }, [hasRecentlyReturnedFromBackground]);

    shouldEnableMaxHeight={canUseTouchScreen()}

    update to

      shouldEnableMaxHeight={shouldEnableMaxHeight()}

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  12. 48 remaining items

  13. melvin-bot commented on Dec 13, 2025

    @melvin-bot

    Triggered auto assignment to @stephanieelliott (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  14. dominictb commented on Dec 16, 2025

    @dominictb
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: NA. This is an edge case.

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: NA

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

      NA. This is an edge case.

  15. stephanieelliott commented on Dec 20, 2025

    @stephanieelliott
    Contributor

    Payment Summary

    Contributor: @dmkt9 due $250 via Upwork - offer extended, please accept it: https://www.upwork.com/nx/wm/offer/109875423 PAID
    Contributor+: @dominictb paid $250 via Upwork PAID

  16. dmkt9 commented on Dec 20, 2025

    @dmkt9
    Contributor

    @stephanieelliott Thank you. Payment requested.

  17. Christinadobrzyn commented on Dec 22, 2025

    @Christinadobrzyn
    Contributor

    awesome! thanks for watching this @stephanieelliott!

    @dominictb are you paid via Upwork or ND?

  18. dominictb commented on Dec 23, 2025

    @dominictb
    Contributor

    @Christinadobrzyn This should be paid via Upwork because it was assigned before my NewDot eligibility date. Please proceed with Upwork offer.

  19. Christinadobrzyn commented on Dec 23, 2025

    @Christinadobrzyn
    Contributor

    Thanks @dominictb! Can you accept this offer? https://www.upwork.com/nx/wm/offer/109907169

  20. dominictb commented on Dec 24, 2025

    @dominictb
    Contributor

    Thanks @Christinadobrzyn I accepted the offer

  21. Christinadobrzyn commented on Dec 24, 2025

    @Christinadobrzyn
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in review

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions