Skip to content

[$125] Wallet - Country search scrolls to incorrect line for some letters #58017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
8 tasks done
IuliiaHerets opened this issue Mar 7, 2025 · 22 comments
Closed
8 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Mar 7, 2025

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.1.10-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Yes, reproducible on both
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5702032
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team
Device used: MacOS 14.7.4 / Safari, Chrome, Desktop. iPhone 15 Pro / 18.3.1. Google Pixel 5 / Android 14
App Component: User Settings

Action Performed:

  1. Login to NewDot with a new Expensifail account
  2. Go to Settings > Wallet
  3. Click Add bank account
  4. Verify your country is selected by default (eg. United States)
  5. In the search bar, enter the first letter of another country. For example - N, A, D, E etc.
  6. Select another country (eq. Cambodia) and try searching by letters again.

Expected Result:

Country search scrolls to the correct country starting with these letters.

Actual Result:

For some first letters the country search scrolls to countries that start with a different letter. Incorrect letters will vary depending on the country already selected by default.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6763951_1741350688270.iOS-Wallet-Search-Incorrect-Scroll.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021898763466530762704
  • Upwork Job ID: 1898763466530762704
  • Last Price Increase: 2025-03-09
  • Automatic offers:
    • FitseTLT | Contributor | 106479043
Issue OwnerCurrent Issue Owner: @ahmedGaber93
@IuliiaHerets IuliiaHerets added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Mar 7, 2025
Copy link

melvin-bot bot commented Mar 7, 2025

Triggered auto assignment to @mallenexpensify (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.

@FitseTLT
Copy link
Contributor

FitseTLT commented Mar 7, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-03-07 16:15:55 UTC.

Proposal

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

Wallet - Country search scrolls to incorrect line for some letters

What is the root cause of that problem?

When the search key contains letters from the currently selected item, the selected item will still be in the list but its index might change (because the relative index will change as the number of items above it change) then setFocusedIndex will be called with the current new index of the selected item

const selectedItemIndex = useMemo(
() => (initiallyFocusedOptionKey ? flattenedSections.allOptions.findIndex((option) => option.isSelected) : -1),
[flattenedSections.allOptions, initiallyFocusedOptionKey],
);
useEffect(() => {
if (selectedItemIndex === -1 || selectedItemIndex === focusedIndex) {
return;
}
setFocusedIndex(selectedItemIndex);
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [selectedItemIndex]);

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

This feature is implemented in #54457 but caused this issue. So we should disable it if there is a search string like:

if (selectedItemIndex === -1 || selectedItemIndex === focusedIndex) {
return;

 if (selectedItemIndex === -1 || selectedItemIndex === focusedIndex || textInputValue) {
            return;

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

The test created for the original pr suffices.

What alternative solutions did you explore? (Optional)

@nyomanjyotisa
Copy link
Contributor

Proposal

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

Wallet - Country search scrolls to incorrect line for some letters

What is the root cause of that problem?

We update the focusedIndex once the flattenedSections.allOptions is updated. This is necessary to update the focusedIndex when there is a changes on Backend especially for Priority mode selection in this issue #54457

But, we also update the focusedIndex when the new data of flattenedSections.allOptions coming from search result

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

Return early if the new data of flattenedSections.allOptions coming from search result

useEffect(() => {
if (selectedItemIndex === -1 || selectedItemIndex === focusedIndex) {
return;
}
setFocusedIndex(selectedItemIndex);
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, [selectedItemIndex]);

    useEffect(() => {
        if (selectedItemIndex === -1 || selectedItemIndex === focusedIndex || prevTextInputValue !== textInputValue) {
            return;
        }
        setFocusedIndex(selectedItemIndex);
        // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
    }, [selectedItemIndex]);

Additionally we can set focus to the default value if the textInputValue empty if needed

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

N/A

What alternative solutions did you explore? (Optional)

Or we can do like this instead of using existing prevTextInputValue value

const prevTextInputValueRef = useRef(textInputValue);

useEffect(() => {
    if (prevTextInputValueRef.current !== textInputValue) {
        prevTextInputValueRef.current = textInputValue;
        return;
    }

    if (selectedItemIndex === -1 || selectedItemIndex === focusedIndex) {
        return;
    }

    setFocusedIndex(selectedItemIndex);
}, [selectedItemIndex]);

@mallenexpensify mallenexpensify changed the title Wallet - Country search scrolls to incorrect line for some letters [$125] Wallet - Country search scrolls to incorrect line for some letters Mar 9, 2025
@melvin-bot melvin-bot bot added the Overdue label Mar 9, 2025
Copy link

melvin-bot bot commented Mar 9, 2025

⚠️ Could not update price automatically because there is no linked Upwork Job ID. The BZ team member will need to update the price manually in Upwork.

@mallenexpensify mallenexpensify added External Added to denote the issue can be worked on by a contributor and removed Overdue labels Mar 9, 2025
@melvin-bot melvin-bot bot added the Overdue label Mar 9, 2025
Copy link

melvin-bot bot commented Mar 9, 2025

Job added to Upwork: https://www.upwork.com/jobs/~021898763466530762704

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 9, 2025
Copy link

melvin-bot bot commented Mar 9, 2025

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

@melvin-bot melvin-bot bot removed the Overdue label Mar 9, 2025
@mallenexpensify
Copy link
Contributor

Hoping it's a quick fix, if not, we can bump the price up.

@dangrous dangrous self-assigned this Mar 10, 2025
@dangrous
Copy link
Contributor

i can grab internal review on this when it's ready!

@ahmedGaber93
Copy link
Contributor

Thanks all for the proposals.

@FitseTLT your RCA looks correct, but after removing these dependencies the focusedIndex will not update if flattenedSections.allOptions was changed in the higher component (e.g. data changed on onyxDB), also it will not back focus to the defaultValue after clear textInputValue and instead will focus first item.

@nyomanjyotisa your RCA missed why some letters works and some not, and with your fix the issue is still reproduced if we search by letters from the selected item, e.g. if you search by letter a when selected item is united states the focus will temporarily move up to the countries that start with letter a them back again to united states.

video
20250311003719549.mp4

@FitseTLT
Copy link
Contributor

@ahmedGaber93 Updated

@ahmedGaber93
Copy link
Contributor

@FitseTLT's proposal by early return if textInputValue is not empty LGTM!

Plus his proposal explanation, textInputValue is not empty here mean user is searching and the focusedIndex is set to the first result item (index 0) not to initiallyFocusedOptionKey, and in this case no need to update focusedIndex to initiallyFocusedOptionKey(the logic that cause the issue)

🎀 👀 🎀 C+ reviewed.

Copy link

melvin-bot bot commented Mar 10, 2025

Current assignee @dangrous is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@dangrous
Copy link
Contributor

sounds good!

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 11, 2025
Copy link

melvin-bot bot commented Mar 11, 2025

📣 @FitseTLT 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Mar 12, 2025
@mallenexpensify mallenexpensify removed their assignment Mar 28, 2025
@mallenexpensify mallenexpensify added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels Mar 28, 2025
Copy link

melvin-bot bot commented Mar 28, 2025

Triggered auto assignment to @jliexpensify (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.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Mar 28, 2025
@mallenexpensify
Copy link
Contributor

@jliexpensify I'm going to be OOO and offline for two weeks so I'm reassigning, will pick back up upon my return, thx

@mallenexpensify mallenexpensify self-assigned this Mar 28, 2025
@FitseTLT
Copy link
Contributor

Payment is due today

@ahmedGaber93
Copy link
Contributor

BugZero Checklist:

  • [Contributor] Classify the bug:
Bug classification

Source of bug:

  • 1a. Result of the original design (eg. a case wasn't considered)
  • 1b. Mistake during implementation
  • 1c. Backend bug
  • 1z. Other:

Where bug was reported:

  • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
  • 2b. Reported on staging (eg. found during regression or PR testing)
  • 2d. Reported on a PR
  • 2z. Other:

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other: Applause Internal Team
  • [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: https://github.com/Expensify/App/pull/54457/files#r2019991575

  • [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: N/A

  • [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.

  • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

    Link to issue:

Regression Test Proposal

Test:

  1. Go to Settings > Wallet
  2. Click Add bank account
  3. Verify your country is selected by default (e.g. United States)
  4. In the search bar, enter the first letter of another country which is also in the selected country. For example - N, A, D, E for United States etc.
  5. Verify it scrolls and focuses on the first item in the search result.
  6. clear search text
  7. Verify it scrolls back and focus on the selected item.

Do we agree 👍 or 👎

@ahmedGaber93
Copy link
Contributor

@jliexpensify It looks the automation was failed here, this issue was due for payment yesterday.

Image

@jliexpensify
Copy link
Contributor

Payment Summary

Upwork job

@jliexpensify
Copy link
Contributor

Paid and job closed.

@JmillsExpensify
Copy link

$125 approved for @ahmedGaber93

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests

8 participants