Skip to content

[Due for payment 2025-05-22] Workspace - Unable to search for a member using the number #61752

Closed

Description

@mitarachim

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.1.43-3
Reproducible in staging?: Yes
Reproducible in production?: Unable to check
If this was caught during regression testing, add the test name, ID and link from TestRail: #61746
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Device used: Windows 11 / Chrome, Android 13 / Xiaomi Poco F5, iOS 15.8.3 / iPhone 7 Plus
App Component: Workspace Settings

Action Performed:

Precondition:

  • Have a workspace with at least 16 members.
  • At least one member has number as last name
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Members.
  3. Search for the member with using number

Expected Result:

The number can be used for searching a member.
Typing a random number should have a function and return no result match.

Actual Result:

Unable to search for a member using the number.
Typing any random number also will not have any function.

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

Bug6826252_1746759068004.61626_-_61746_-_Workspace_-_Unable_to_search_for_a_member_using_the_number.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @joekaufmanexpensify

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    DeployBlockerIndicates it should block deploying the API
    on May 9, 2025
  2. melvin-bot commented on May 9, 2025

    @melvin-bot

    Triggered auto assignment to @MonilBhavsar (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  3. melvin-bot commented on May 9, 2025

    @melvin-bot

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

  4. melvin-bot commented on May 9, 2025

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  5. github-actions commented on May 9, 2025

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. daledah commented on May 9, 2025

    @daledah
    Contributor

    Coming from #61746

  7. olivierhabi commented on May 9, 2025

    @olivierhabi

    Proposal

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

    When searching for workspace members:

    1. If a user types a purely numeric string that does not correspond to any part of a member's display name or email (e.g., a random sequence like "848172361927498127498"), the member list is not filtered, and no "No results found" message is displayed. It should show "No results found."
    2. Users expect to be able to search for members if a number is part of their display name (e.g., searching "123" should find a member named "John 123").
    3. If a member's display name is itself a number (e.g., "777"), searching for that number should find the member.

    The core issue is that the search logic needs to correctly handle numeric inputs for all these cases, using both direct string matching for numbers and normalized string matching for diacritics/other characters.

    What is the root cause of that problem?

    The root cause of the original "full list" bug for non-matching numeric searches is that the searchQuery (e.g., "99999") after being processed by StringUtils.normalize() likely becomes an empty string (""). When this empty string is used in String.prototype.includes(""), it returns true for every member, thus showing the full list.

    The extended requirement to search for numbers within names wasn't fully covered by a simple fix for the above, as that fix might have been too restrictive if it only considered cases where the entire normalized name matched an empty normalized query.

    The useSearchResults hook provides the filterMember function with an already trimmed and lowercased search query. The filterMember function then needs to intelligently use this query for both direct (number-inclusive) matching and StringUtils.normalize'd matching (for diacritics, etc.), while carefully handling the case where a normalized search query becomes empty.

    const filterMember = useCallback((memberOption: MemberOption, searchQuery: string) => {
    const memberText = StringUtils.normalize(memberOption.text?.toLowerCase() ?? '');
    const alternateText = StringUtils.normalize(memberOption.alternateText?.toLowerCase() ?? '');
    const normalizedSearchQuery = StringUtils.normalize(searchQuery);
    return memberText.includes(normalizedSearchQuery) || alternateText.includes(normalizedSearchQuery);
    }, []);

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

    We will modify the filterMember function within WorkspaceMembersPage.js.

    The approach is two-tiered:

    1. Direct Lowercase Substring Search: First, we'll perform a direct, case-insensitive substring search using the (already trimmed and lowercased) searchQuery from useSearchResults against the lowercased versions of the member's display name (memberOption.text) and alternate text (memberOption.alternateText). If a match is found here (e.g., searching "123" in "John 123"), we return true. This immediately satisfies searching for numbers within names.

    2. Normalized Search (Fallback): If the direct search yields no match (e.g., searching "jose" for a member "José"), we then proceed to a search using StringUtils.normalize on both the member fields and the searchQuery.

      • The member's display name and alternate text are normalized.
      • The searchQuery is also normalized.
      • Crucially, if the searchQuery was non-empty but its normalized version becomes an empty string (e.g., "99999" normalizes to ""), we only consider it a match if the member's normalized text or alternate text is also an empty string. This handles finding members named "777" (if "777" normalizes to "") while correctly filtering out all other members for a query like "99999", thus triggering "No results found."
      • If the normalized search query is not empty, a standard includes check is performed on the normalized strings. This handles diacritic-insensitive searches like "jose" for "José".

    This combined approach ensures numbers are searchable within names, purely numeric names are findable, general search works, and the "full list for random numbers" bug is fixed.

    const filterMember = useCallback((memberOption: MemberOption, searchQuery: string) => {
            const memberText = (memberOption.text ?? '').toLowerCase();
            const memberAlternateTextLc = (memberOption.alternateText ?? '').toLowerCase();
    
            if (memberText.includes(searchQuery) || memberAlternateTextLc.includes(searchQuery)) {
                return true;
            }
            
            const normalizedMemberText = StringUtils.normalize(memberOption.text ?? '');
            const normalizedAlternateText = StringUtils.normalize(memberOption.alternateText ?? '');
            const fullyNormalizedSearchQuery = StringUtils.normalize(searchQuery);
    
            if (searchQuery !== '' && fullyNormalizedSearchQuery === '') {
                return normalizedMemberText === '' || normalizedAlternateText === '';
            }
            return normalizedMemberText.includes(fullyNormalizedSearchQuery) || normalizedAlternateText.includes(fullyNormalizedSearchQuery);
        }, []);
    
    

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

    None

    What alternative solutions did you explore? (Optional)

    None

    Result

    Screen.Recording.2025-05-09.at.08.52.59.mov
  8. 4 remaining items

  9. melvin-bot commented on May 10, 2025

    @melvin-bot

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

    If a regression has occurred and you are the assigned CM follow the instructions here.

    If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

  10. MonilBhavsar commented on May 12, 2025

    @MonilBhavsar
    Contributor

    Issue was fixed. Closing

  11. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on May 15, 2025
  12. changed the title [-]Workspace - Unable to search for a member using the number[/-] [+][Due for payment 2025-05-22] Workspace - Unable to search for a member using the number[/+] on May 15, 2025
  13. melvin-bot commented on May 15, 2025

    @melvin-bot

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

  14. melvin-bot commented on May 15, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.45-21 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 2025-05-22. 🎊

  15. melvin-bot commented on May 15, 2025

    @melvin-bot

    @MonilBhavsar @joekaufmanexpensify @MonilBhavsar The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

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.DeployBlockerIndicates it should block deploying the APIEngineeringWeeklyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions