Skip to content

[HOLD for payment 2024-02-14] [$500] [Wave 5] [ECard Settings] App crashes when pressing back button when activating physical expensify card #34875

Closed

Description

@kavimuru

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:
Reproducible in staging?: needs reproduction
Reproducible in production?: needs reproduction
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @mountiny
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1705661461207919

Action Performed:

Prerequisites:

  • Have a physical card to activate
  • Alternatively (if on dev) you can add this effect to WalletPage.js to create a mock card:
  1. Navigate to the WalletPage
  2. Navigate to Expensify Card
  3. Click the Activate physical card button
  4. The native keyboard is necessary for reproduction but it will be closed by default, to enable it you have to manually focus some digit of the activation code (e.g. the 4th one), that should toggle the native keyboard
  5. Once the native keyboard is toggled, dismiss it by pressing anywhere on the screen
  6. Once it’s dismissed press the < button on the screen keyboard (the custom one)

Expected Result:

App should not crash

Actual Result:

App crashed

Workaround:

unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

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

Screenshots/Videos

Add any screenshot/video evidence

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01a4febea3f9721613
  • Upwork Job ID: 1749410465588416512
  • Last Price Increase: 2024-01-26
  • Automatic offers:
    • DylanDylann | Reviewer | 28131636
    • akinwale | Contributor | 28131637

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jan 22, 2024
  2. changed the title [-]App crashes when pressing back button when activating physical expensify card[/-] [+][$500] App crashes when pressing back button when activating physical expensify card[/+] on Jan 22, 2024
  3. melvin-bot commented on Jan 22, 2024

    @melvin-bot
  4. changed the title [-][$500] App crashes when pressing back button when activating physical expensify card[/-] [+][Wave 5] App crashes when pressing back button when activating physical expensify card[/+] on Jan 22, 2024
  5. akinwale commented on Jan 22, 2024

    @akinwale
    Contributor

    Is there a video of the test steps to reproduce the bug?

  6. moved this to Release 4: Card Experience in [#whatsnext] Wave 05 - Deprecate Freeon Jan 22, 2024
  7. akinwale commented on Jan 22, 2024

    @akinwale
    Contributor

    Proposal

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

    The app crashes if a user presses the Backspace button on the Big Number Pad (BNP) after dismissing the soft keyboard on a native device.

    What is the root cause of that problem?

    Tapping anywhere to dismiss the soft keyboard causes the MagicCodeInput to lose focus, thereby calling setFocusedIndex(undefined); to null in the onBlur handler.

    setFocusedIndex(undefined);

    Upon the next press of the Backspace button, we're trying to focus on a non-existent ref which triggers the error.

    inputRefs.current[indexToFocus].focus();

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

    Solution 1
    Check that the indexToFocus is not undefined before calling the focus method in MagicCodeInput.

    +if (!indexToFocus) {
    +    return;
    +}
    inputRefs.current[indexToFocus].focus();

    Solution 2
    Ensure that the MagicCodeInput is focused before dispatching a key press from the BNP.

    We can do this in the updateLastPressedDigit callback in ActivatePhysicalCardPage.

    const updateLastPressedDigit = useCallback((key) => setLastPressedDigit(lastPressedDigit === key ? lastPressedDigit + key : key), [lastPressedDigit]);

    -const updateLastPressedDigit = useCallback((key) => setLastPressedDigit(lastPressedDigit === key ? lastPressedDigit + key : key), [lastPressedDigit]);
    +const updateLastPressedDigit = useCallback((key) => {
    +    if (activateCardCodeInputRef.current) {
    +       activateCardCodeInputRef.current.focus();
    +    }
    +    setLastPressedDigit(lastPressedDigit === key ? lastPressedDigit + key : key);
    +    
    +}, [lastPressedDigit]);

    Note that this will also cause the soft keyboard to be displayed again every time the input regains focus, so we would need to add a ref to check if the soft keyboard has already been dismissed to prevent it from being shown again while the screen is still active.

    What alternative solutions did you explore? (Optional)

    None.

  8. akinwale commented on Jan 22, 2024

    @akinwale
    Contributor

    Proposal

    Updated

  9. situchan commented on Jan 22, 2024

    @situchan
    Contributor

    Seems like the same root cause as #18874

  10. akinwale commented on Jan 22, 2024

    @akinwale
    Contributor

    Seems like the same root cause as #18874

    Yeah, looks like it. However, the underlying cause of that issue was fixed. This is triggered due to expected user action.

  11. 32 remaining items

  12. melvin-bot commented on Feb 7, 2024

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  13. melvin-bot commented on Feb 7, 2024

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.37-7 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2024-02-14. 🎊

    For reference, here are some details about the assignees on this issue:

  14. melvin-bot commented on Feb 7, 2024

    @melvin-bot

    BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

    • [@akinwale / @DylanDylann] The PR that introduced the bug has been identified. Link to the PR:
    • [@akinwale / @DylanDylann] 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:
    • [@akinwale / @DylanDylann] A discussion in #expensify-bugs 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:
    • [@akinwale / @DylanDylann] Determine if we should create a regression test for this bug.
    • [@akinwale / @DylanDylann] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
    • [] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  15. DylanDylann commented on Feb 14, 2024

    @DylanDylann
    Contributor

    BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

    [@DylanDylann] The PR that introduced the bug has been identified. Link to the PR: NA
    [@DylanDylann] 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
    [@DylanDylann] A discussion in #expensify-bugs 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
    [@DylanDylann] Determine if we should create a regression test for this bug. Yes
    [@DylanDylann] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

    Regression Test Proposal

    1. Launch the Expensify app.
    2. Navigate to the Wallet page.
    3. Click or tap on the Activate physical card button.
    4. Dismiss the soft keyboard that is shown so that the magic code input loses focus. (The soft keyboard showing up and getting dismissed is a required step for the test).
    5. Press the Backspace button at the bottom right of the BNP.
    6. Verify that the app does not crash.

    Do we agree 👍 or 👎

  16. melvin-bot commented on Feb 14, 2024

    @melvin-bot

    Issue is ready for payment but no BZ is assigned. @greg-schroeder you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks!

  17. greg-schroeder commented on Feb 14, 2024

    @greg-schroeder
    Contributor

    Paid, filed regression test, closing

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorNeeds ReproductionReproducible steps needed

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions