Skip to content

[$500] iOS - Request Money - Searching for specific HT account while using HT account has an odd behavior #30803

Closed

Description

@kbecciv

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: 1.3.95.0
Reproducible in staging?: y
Reproducible in production?: y
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: Applause - Internal Team
Slack conversation:

Issue found when executing PR #30591

Action Performed:

Pre-requisite: user must be logged in with a HT account.

  1. Tap on "+" button.
  2. Tap on "Request money".
  3. Select "Manual".
  4. Enter any amount and tap on "Next".
  5. Search for a specific HT account, such as "applausetester+vd_htmain@applause.expensifail.com".

Expected Result:

The search results should only show the requested account.

Actual Result:

The account being searched is at the top of the list, but then reappears at the bottom constantly changing avatars.

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

Bug6261440_1698958778867.Upyl2566_1_.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01c1e5f3f5dad45859
  • Upwork Job ID: 1720190449397870592
  • Last Price Increase: 2023-11-02

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Nov 2, 2023
  2. changed the title [-]iOS - Request Money - Searching for specific HT account while using HT account has an odd behavior[/-] [+][$500] iOS - Request Money - Searching for specific HT account while using HT account has an odd behavior[/+] on Nov 2, 2023
  3. melvin-bot commented on Nov 2, 2023

    @melvin-bot
  4. melvin-bot commented on Nov 2, 2023

    @melvin-bot

    Triggered auto assignment to @puneetlath (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Nov 2, 2023
  6. melvin-bot commented on Nov 2, 2023

    @melvin-bot

    Bug0 Triage Checklist (Main S/O)

    • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
    • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
      • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
    • This bug is reproducible using the reproduction steps in the OP. S/O
      • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
      • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
    • This issue is filled out as thoroughly and clearly as possible
      • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
    • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
  7. melvin-bot commented on Nov 2, 2023

    @melvin-bot

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

  8. orshikh-dev commented on Nov 3, 2023

    @orshikh-dev

    Proposal

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

    The account being searched is at the top of the list, but then reappears at the bottom constantly changing avatars.

    What is the root cause of that problem?

    It shows an existing account with a specific existing email and it also adds a non-existed account with non-existed email.

    When we are searching with some text, search input sends a search term for every single character. In every request, it will call this method, this method returns all list options:

    const sections = useMemo(() => {
    const newSections = [];
    let indexOffset = 0;
    const formatResults = OptionsListUtils.formatSectionsFromSearchTerm(
    searchTerm,
    participants,
    newChatOptions.recentReports,
    newChatOptions.personalDetails,
    personalDetails,
    true,
    indexOffset,
    );
    newSections.push(formatResults.section);
    indexOffset = formatResults.newIndexOffset;
    if (maxParticipantsReached) {
    return newSections;
    }
    newSections.push({
    title: translate('common.recents'),
    data: newChatOptions.recentReports,
    shouldShow: !_.isEmpty(newChatOptions.recentReports),
    indexOffset,
    });
    indexOffset += newChatOptions.recentReports.length;
    newSections.push({
    title: translate('common.contacts'),
    data: newChatOptions.personalDetails,
    shouldShow: !_.isEmpty(newChatOptions.personalDetails),
    indexOffset,
    });
    indexOffset += newChatOptions.personalDetails.length;
    if (newChatOptions.userToInvite && !OptionsListUtils.isCurrentUser(newChatOptions.userToInvite)) {
    newSections.push({
    undefined,
    data: _.map([newChatOptions.userToInvite], (participant) => {
    const isPolicyExpenseChat = lodashGet(participant, 'isPolicyExpenseChat', false);
    return isPolicyExpenseChat ? OptionsListUtils.getPolicyExpenseReportOption(participant) : OptionsListUtils.getParticipantsOption(participant, personalDetails);
    }),
    shouldShow: true,
    indexOffset,
    });
    }
    return newSections;
    }, [maxParticipantsReached, newChatOptions, participants, personalDetails, translate, searchTerm]);

    If we find a user with a specific email, that user will be added to sections

    const formatResults = OptionsListUtils.formatSectionsFromSearchTerm(
    searchTerm,
    participants,
    newChatOptions.recentReports,
    newChatOptions.personalDetails,
    personalDetails,
    true,
    indexOffset,
    );
    newSections.push(formatResults.section);

    And if a user does not exist, we add non-existing users into sections as well,

    if (newChatOptions.userToInvite && !OptionsListUtils.isCurrentUser(newChatOptions.userToInvite)) {
    newSections.push({
    undefined,
    data: _.map([newChatOptions.userToInvite], (participant) => {
    const isPolicyExpenseChat = lodashGet(participant, 'isPolicyExpenseChat', false);
    return isPolicyExpenseChat ? OptionsListUtils.getPolicyExpenseReportOption(participant) : OptionsListUtils.getParticipantsOption(participant, personalDetails);
    }),
    shouldShow: true,
    indexOffset,
    });
    }
    return newSections;

    There are 2 possible cases:
    CASE 1: THE USER DOES NOT EXIST
    Non-existing user is added into sections, no issues:

    if (newChatOptions.userToInvite && !OptionsListUtils.isCurrentUser(newChatOptions.userToInvite)) {
    newSections.push({
    undefined,
    data: _.map([newChatOptions.userToInvite], (participant) => {
    const isPolicyExpenseChat = lodashGet(participant, 'isPolicyExpenseChat', false);
    return isPolicyExpenseChat ? OptionsListUtils.getPolicyExpenseReportOption(participant) : OptionsListUtils.getParticipantsOption(participant, personalDetails);
    }),
    shouldShow: true,
    indexOffset,
    });
    }
    return newSections;

    CASE 2: USER EXIST
    In this case, the user will be added to the section, just like this:

    But, in every single valid email address, it will be a non-existent user:
    For example applausetester+vd_htmain@applause.expensifail.com

    Existed user:
    If the email address is valid, it will be added into sections:
    applausetester+vd_htmain@applause.e is enough, not required to be whole email, just valid, existed email pattern is enough

    Non-existed users with valid emails:
    applausetester+vd_htmain@applause.e <= here we know this email is valid and found existed user with this email
    applausetester+vd_htmain@applause.ex
    applausetester+vd_htmain@applause.exp
    applausetester+vd_htmain@applause.expe
    applausetester+vd_htmain@applause.expen
    . . .
    applausetester+vd_htmain@applause.expensifail.co <= till, not whole email address

    That's why the avatar is changing because, for every valid email, for every single character, it will send a request, in every request, the non-exist user(all different user) will be added into sections, in this example, for all characters in this text [xpensifail.co]. The email was so long, so we didn't see it was changing in the row.

    Please see from this video:
    https://drive.google.com/file/d/1LOnmzTz-fSW9oCk-p55pkh0PlKRmRBv0/view?usp=sharing

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

    1. We need to improve UX. We can make some changes to the email address, maybe we can concat from the middle, or concat from the head, now it is concating from the tail.
    image

    Concating from head:
    image

    Concating from middle:
    image

    1. We can make other UX design changes, user can easily understand what is going on.

    What alternative solutions did you explore? (Optional)

    Or we can set a limit on email length, so it can't be that long to be out of the screen. In example, 42 character length email:
    image

    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.

  9. rojiphil commented on Nov 3, 2023

    @rojiphil
    Contributor

    Proposal

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

    In request money participants selector page, the search results keeps getting constantly updated (i.e avatar, search result itself) even after the user has stopped entering the search value. This is the problem we are trying to solve here.

    What is the root cause of that problem?

    When a long search text is entered (e.g. applausetester+vd_htmain@applause.expensifail.com), this will generate many API requests to the server for reports as shown here. Since each of these responses will come back at some time later and trigger the useEffect here, updation of the sections here will get delayed in a HT environment with lots of results.

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

    We can solve this problem by debouncing the updation of chat options thereby saving processing time which will matter a lot in a HT environment.

    1. We can move the contents of useEffect here into a new function updateChatOptions like this
        const updateChatOptions = useCallback(() => {
           // Contents of useEffect here  
        }, [betas, reports, participants, personalDetails, translate, searchTerm, setNewChatOptions, iouType, isDistanceRequest]);
    
    1. Debouncing the updateChatOptions can be done like this here
        useEffect(() => {
            const debouncedFetchChatOptions = _.debounce(updateChatOptions, 200);
            debouncedFetchChatOptions();
            return () => {
                debouncedFetchChatOptions.cancel();
            };
        }, [updateChatOptions]);
    

    What alternative solutions did you explore? (Optional)

  10. melvin-bot commented on Nov 6, 2023

    @melvin-bot

    @puneetlath, @mananjadhav Whoops! This issue is 2 days overdue. Let's get this updated quick!

  11. 42 remaining items

  12. melvin-bot commented on Dec 12, 2023

    @melvin-bot

    @puneetlath, @situchan Eep! 4 days overdue now. Issues have feelings too...

  13. situchan commented on Dec 12, 2023

    @situchan
    Contributor

    Reviewed all conversations. reviewing proposals.

  14. puneetlath commented on Dec 15, 2023

    @puneetlath
    Contributor

    Let us know your thoughts @situchan

  15. situchan commented on Dec 19, 2023

    @situchan
    Contributor

    I tested on latest main and the behavior is not that odd.
    @rojiphil can you please retest and share video?
    FYI: debounce was introduced in #32962 and just deployed to staging

  16. melvin-bot commented on Dec 22, 2023

    @melvin-bot

    @puneetlath, @situchan Whoops! This issue is 2 days overdue. Let's get this updated quick!

  17. puneetlath commented on Dec 22, 2023

    @puneetlath
    Contributor

    I'm going to go ahead and close this issue based on @situchan's experience. @rojiphil feel free to let us know if you think otherwise and we can reopen if there is something to fix.

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.DailyKSv2EngineeringInternalRequires API changes or must be handled by Expensify staff

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions