Skip to content
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

[HOLD for payment 2024-10-29] [$250] Submit Expense - Contacts section is missing participants #48114

Closed
1 of 6 tasks
lanitochka17 opened this issue Aug 27, 2024 · 81 comments
Closed
1 of 6 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@lanitochka17
Copy link

lanitochka17 commented Aug 27, 2024

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.0.25-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: https://expensify.testrail.io/index.php?/tests/view/4890824&group_by=cases:section_id&group_order=asc&group_id=229066
Issue reported by: Applause - Internal Team

Action Performed:

  1. Sign up for a new account on staging.new.expensify.com
  2. Create DMs with 7 new contacts
  3. Go to Global Create > Submit Expense
  4. Enter an amount and click Next
  5. Observe the missing participants from the Contacts section.

Expected Result:

During the expense submitting or splitting process, the search list, should be divided in "Recents" and "Contacts"

All of your DM contacts should be in the contacts section.

Actual Result:

Some contacts are missing.

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

Screenshot 2024-10-16 at 9 33 01 PM
Bug6584155_1724766273965.Contacts-Recents.mp4

ontacts-Recent (1)

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~016d2f5d8be09bffb6
  • Upwork Job ID: 1829406098502441268
  • Last Price Increase: 2024-10-04
  • Automatic offers:
    • c3024 | Contributor | 104318599
Issue OwnerCurrent Issue Owner: @RachCHopkins
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 27, 2024
Copy link

melvin-bot bot commented Aug 27, 2024

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

@lanitochka17
Copy link
Author

@kadiealexander FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

@tsa321
Copy link
Contributor

tsa321 commented Aug 28, 2024

Edited by proposal-police: This proposal was edited at 2024-08-28 06:51:06 UTC.

Proposal

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

Search list when submitting expense, doesn't display contacts section

What is the root cause of that problem?

When submitting an expense, if there is no chat history with a contact in the contact list, it will be included in the Contacts section. However, if there is chat history, it will be included in recentReports or just Chats. The issue is that recentReports is limited to a maximum of 5 recent reports (because of the slice and splice in below code), causing the remaining reports to be discarded:

if (searchInputValue.trim() === '' && maxRecentReportsToShow > 0) {
return {...options, recentReports: options.recentReports.slice(0, maxRecentReportsToShow)};
}

and here:

if (maxRecentReportsToShow > 0 && recentReports.length > maxRecentReportsToShow) {
recentReports.splice(maxRecentReportsToShow);
}

As a result, it seems that some contacts are missing, and many reports are not displayed due to this filtering (slice / splice).

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

We could store the remaining reports from recentReports into a separate olderReports (or another name) data and return it to the caller in MoneyRequestParticipantsSelector (must check other caller if necessary).

When generating section data:

newSections.push(formatResults.section);
newSections.push({
title: translate('common.recents'),
data: chatOptions.recentReports,
shouldShow: chatOptions.recentReports.length > 0,
});
newSections.push({
title: translate('common.contacts'),
data: chatOptions.personalDetails,
shouldShow: chatOptions.personalDetails.length > 0,
});

include the olderReports data. The sketch code changes could be something like this. We must also check other usage of filterOptions and adjust the code accordingly. and If we want to re-order the olderReports by other criteria (other than date), we can adjust it there.

What alternative solutions did you explore? (Optional)

The alternative solution is to retrieve DM reports from older or discarded reports and include them in the contact list.

@melvin-bot melvin-bot bot added the Overdue label Aug 29, 2024
@kadiealexander kadiealexander added the External Added to denote the issue can be worked on by a contributor label Aug 30, 2024
Copy link

melvin-bot bot commented Aug 30, 2024

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

@melvin-bot melvin-bot bot changed the title Submit Expense - Search list when submitting expense, doesn´t display the contacts section [$250] Submit Expense - Search list when submitting expense, doesn´t display the contacts section Aug 30, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Aug 30, 2024
Copy link

melvin-bot bot commented Aug 30, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label Aug 30, 2024
@c3024
Copy link
Contributor

c3024 commented Sep 1, 2024

Edited by proposal-police: This proposal was edited at 2024-09-19 10:01:46 UTC.

Proposal

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

Contacts section is missing in the participant selector though they are not included in Recents.

What is the root cause of that problem?

We get defaultOptions here

const defaultOptions = useMemo(() => {

with
const optionList = OptionsListUtils.getFilteredOptions(

and we pass maxRecentReportsToShow as 0 here

which means we do not limit the max recent reports for the result from this function.

getFilteredOptions calls getOptions

return getOptions(

which in turn keeps adding the recent reports and continues adding all because maxRecentReportsToShow is zero.
if (recentReportOptions.length > 0 && recentReportOptions.length === maxRecentReportsToShow) {
break;

Along with this it also excludes the personal detail of these report logins here
if (reportOption.login) {
optionsToExclude.push({login: reportOption.login});
}

Since, we are not limiting the recent reports to show so all these reportOption logins are excluded when processing personal details into options here. So, the default options returned from here includes all recent reports but do not include these personal details.

Back here in the MoneyRequestParticipantsSelector

maxRecentReportsToShow: CONST.IOU.MAX_RECENT_REPORTS_TO_SHOW,

we restrict the reports only to MAX_RECENT_REPORTS_TO_SHOW so only those reports show up and many personal details were already excluded earlier in the default options because of addition of all recent reports as explained earlier.

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

  1. We can consider moving max recent report limit to getFilteredOptions. This works well when there is no search term but when there is a search term the results it return may not include the correct results because the search term is not passed to this function.
  2. Since we are filtering the options based on search term in filterOptions and this is where we are restricting the max reports also to MAX_RECENT_REPORTS_TO_SHOW, we can move the personal details excluding logic to filterOptions.

That is to remove this logic

// Add this login to the exclude list so it won't appear when we process the personal details
if (reportOption.login) {
optionsToExclude.push({login: reportOption.login});
}

of excluding personal details for included reports from getOptions and move that to filterOptions with something like this

if (searchInputValue.trim() === '' && maxRecentReportsToShow > 0) {
        // return {...options, recentReports: options.recentReports.slice(0, maxRecentReportsToShow)};
        const recentReports = options.recentReports.slice(0, maxRecentReportsToShow);
        const excludedLogins = new Set(recentReports.map(report => report.login));
        const filteredPersonalDetails = options.personalDetails.filter(personalDetail => !excludedLogins.has(personalDetail.login));
        return {
            ...options,
            recentReports,
            personalDetails: filteredPersonalDetails,
        };
            
    }

at

if (searchInputValue.trim() === '' && maxRecentReportsToShow > 0) {
return {...options, recentReports: options.recentReports.slice(0, maxRecentReportsToShow)};
}

and

    if (maxRecentReportsToShow > 0 && recentReports.length > maxRecentReportsToShow) {
        recentReports.splice(maxRecentReportsToShow);
    }

    const excludedLogins = new Set(recentReports.map(report => report.login));
    const filteredPersonalDetails = personalDetails.filter(personalDetail => !excludedLogins.has(personalDetail.login));
    personalDetails = filteredPersonalDetails;

at

if (maxRecentReportsToShow > 0 && recentReports.length > maxRecentReportsToShow) {
recentReports.splice(maxRecentReportsToShow);
}

This movement does not break anything because wherever we use getFilteredOptions or getOptions with reports in the repo we also filter those again with filteredOptions.

Here is the branch with these changes.

What alternative solutions did you explore? (Optional)

  1. We can pass the maxReportsToShow to the getFilteredOptions function.
  2. Then we can also pass the debouncedTerm to getFilteredOptions and this is not an expensive operation so doing the filtering with search term in both getFilteredOptions and filterOptions is also a viable solution and it retains the report-contact sections separation within getOptions function itself.

@melvin-bot melvin-bot bot added the Overdue label Sep 1, 2024
Copy link

melvin-bot bot commented Sep 2, 2024

@kadiealexander, @eh2077 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@eh2077
Copy link
Contributor

eh2077 commented Sep 2, 2024

Reviewing proposals

@melvin-bot melvin-bot bot removed the Overdue label Sep 2, 2024
@eh2077
Copy link
Contributor

eh2077 commented Sep 2, 2024

Thanks for your proposals!

I think @c3024 pointed out the correct root cause of this issue. Their solution also looks good to me. So, let's go with @c3024 's proposal

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Sep 2, 2024

Triggered auto assignment to @MonilBhavsar, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@trjExpensify
Copy link
Contributor

Do we know which PR broke this?

@trjExpensify trjExpensify moved this to Release 2.5: SuiteWorld (Sept 9th) in [#whatsnext] #wave-collect Sep 2, 2024
@tsa321
Copy link
Contributor

tsa321 commented Sep 3, 2024

@eh2077, after testing @c3024's proposal by changing:

to CONST.IOU.MAX_RECENT_REPORTS_TO_SHOW, some reports are still missing. I tested it using my account, which has many reports and contacts. Here is in staging with the Workspace report included:

Screenshot 2024-09-03 at 06 57 55

With @c3024's proposal, some reports are missing (notice the missing workspace reports):

some.reports.missing.mp4

With my proposal, all reports are shown (including workspace reports):

my-proposal.mp4

@eh2077 could you re-review my proposal again?
Thank you...

@c3024
Copy link
Contributor

c3024 commented Sep 3, 2024

With @c3024's proposal, some reports are missing (notice the missing workspace reports):

Yes, I missed that.

I think the better solution is the alternative solution proposed. That is to remove this logic

// Add this login to the exclude list so it won't appear when we process the personal details
if (reportOption.login) {
optionsToExclude.push({login: reportOption.login});
}

of excluding personal details for included reports from getOptions and move that to filterOptions with something like this

if (searchInputValue.trim() === '' && maxRecentReportsToShow > 0) {
        // return {...options, recentReports: options.recentReports.slice(0, maxRecentReportsToShow)};
        const recentReports = options.recentReports.slice(0, maxRecentReportsToShow);
        const excludedLogins = new Set(recentReports.map(report => report.login));
        const filteredPersonalDetails = options.personalDetails.filter(personalDetail => !excludedLogins.has(personalDetail.login));
        return {
            ...options,
            recentReports,
            personalDetails: filteredPersonalDetails,
        };
            
    }

at

if (searchInputValue.trim() === '' && maxRecentReportsToShow > 0) {
return {...options, recentReports: options.recentReports.slice(0, maxRecentReportsToShow)};
}

and

    if (maxRecentReportsToShow > 0 && recentReports.length > maxRecentReportsToShow) {
        recentReports.splice(maxRecentReportsToShow);
    }

    const excludedLogins = new Set(recentReports.map(report => report.login));
    const filteredPersonalDetails = personalDetails.filter(personalDetail => !excludedLogins.has(personalDetail.login));
    personalDetails = filteredPersonalDetails;

at

if (maxRecentReportsToShow > 0 && recentReports.length > maxRecentReportsToShow) {
recentReports.splice(maxRecentReportsToShow);
}

This does not require any changes in the individual pages and corrects the common logic.

@tsa321
Copy link
Contributor

tsa321 commented Sep 3, 2024

I’m not sure; changing the logic would require extensive testing on other pages as well.
I believe my proposal is simpler and safer, as it doesn’t alter the logic and only addresses(catch/store) the discarded reports.

@eh2077
Copy link
Contributor

eh2077 commented Sep 5, 2024

@tsa321 I just tested using a high traffic account and it works well, see
image

Are you still able to reproduce it?

@tsa321
Copy link
Contributor

tsa321 commented Sep 5, 2024

@eh2077 I am still able to reproduce the issue. The root cause is that some reports are missing from the list.

Test Steps:

  1. Create a new test account.
  2. Send a dm message to 8 people (using start new chat), make sure to send a message to each one of them.
  3. Begin the submit expense step.
  4. Notice that without entering a search term, only 5 people/items appear on the submit expense list. The remaining 3 are missing, and there is no contact section.
bug-d.mp4

Another Way to Test:

  1. Ensure you have more than 5 expense reports.
  2. Begin the submit expense step.
  3. Notice that without entering a search term, some expense reports are missing.

@kadiealexander kadiealexander added Bug Something is broken. Auto assigns a BugZero manager. and removed Bug Something is broken. Auto assigns a BugZero manager. labels Oct 25, 2024
Copy link

melvin-bot bot commented Oct 25, 2024

Triggered auto assignment to @RachCHopkins (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 Oct 25, 2024
@kadiealexander kadiealexander added Weekly KSv2 and removed Daily KSv2 labels Oct 25, 2024
@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Oct 28, 2024
@RachCHopkins
Copy link
Contributor

@c3024 / @eh2077 can you complete the above checklist, please?

@melvin-bot melvin-bot bot removed the Overdue label Oct 28, 2024
Copy link

melvin-bot bot commented Nov 1, 2024

@MonilBhavsar, @RachCHopkins, @c3024, @eh2077 Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label Nov 1, 2024
@RachCHopkins
Copy link
Contributor

@c3024 @eh2077 I would really love to pay you. Can someone please complete the checklist?

@melvin-bot melvin-bot bot removed the Overdue label Nov 4, 2024
@eh2077
Copy link
Contributor

eh2077 commented Nov 4, 2024

@RachCHopkins Sorry for the late response! I put it on my list and will complete it by EOD.

@eh2077
Copy link
Contributor

eh2077 commented Nov 4, 2024

Checklist

Regression test

  1. Sign up for a new account on staging.new.expensify.com
  2. Create DMs with 7 new contacts
  3. Go to Global Create > Submit Expense
  4. Enter an amount and click Next
  5. Verify that all participants can be found in the Contacts section or the Recents section.

@RachCHopkins
Copy link
Contributor

Thank you - I will get this sorted out on my Monday!

@melvin-bot melvin-bot bot added the Overdue label Nov 8, 2024
@MonilBhavsar
Copy link
Contributor

Thank you!

@RachCHopkins
Copy link
Contributor

Payment Summary:

  • Contributor: @c3024 paid $250 via Upwork
  • Contributor+: @eh2077 to be paid $250 via NewDot manual requests

Upwork job here

@melvin-bot melvin-bot bot removed the Overdue label Nov 10, 2024
@RachCHopkins
Copy link
Contributor

Contributor has been paid, the contract has been completed, and the Upwork post has been closed.

@github-project-automation github-project-automation bot moved this from CRITICAL to Done in [#whatsnext] #quality Nov 10, 2024
@eh2077
Copy link
Contributor

eh2077 commented Nov 11, 2024

Requested payment in NewDot

@JmillsExpensify
Copy link

$250 approved for @eh2077

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
Status: Release 2.5: SuiteWorld (Sept 9th)
Development

No branches or pull requests

9 participants