Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.56k stars 2.9k forks source link

Web - Split Bill - Displaying email address instead of user name in split detail #20768

Closed kbecciv closed 1 year ago

kbecciv commented 1 year ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Go to the split bill feature
  2. Enter the amount and select a user, then click on the Split button
  3. Open the split detail

Expected Result:

The user name should be displayed in the split detail

Actual Result:

Instead of displaying the user name, the email address is shown in the split detail

Workaround:

Unknown

Platforms:

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

Version Number: 1.3.27.4

Reproducible in staging?: Yes

Reproducible in production?: n/a

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

Notes/Photos/Videos: Any additional supporting documentation

https://github.com/Expensify/App/assets/93399543/e18ac51a-ae92-4555-8543-e3ca40bc32f1

https://github.com/Expensify/App/assets/93399543/869aaaa4-b832-4b78-a7f4-eaee81472b86

Expensify/Expensify Issue URL:

Issue reported by: @ayazhussain79

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1686216389868629

View all open jobs on GitHub

melvin-bot[bot] commented 1 year ago

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

melvin-bot[bot] commented 1 year ago

Bug0 Triage Checklist (Main S/O)

kbecciv commented 1 year ago

Proposal

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

On Split detail displaying email address instead of user name in split detail

What is the root cause of that problem?

The problem stems from the "OptionListUtils.js" file, specifically within the "getIOUConfirmationOptionsFromPayeePersonalDetail" function. The displayName variable is empty in this function, resulting in the addition of email addresses instead of user names.

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

To resolve this issue, we suggest making the following changes in the "getIOUConfirmationOptionsFromPayeePersonalDetail" function:

  1. Add the user name to the displayName variable. If the first name and last name are not empty, concatenate them and assign the value to displayName.
  2. Utilize the trim function to remove any leading or trailing spaces in the displayName variable to ensure clean display.

    What alternative solutions did you explore? (Optional)

    NA

Nikhil-Vats commented 1 year ago

Proposal

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

Split Bill shows email address instead of user name in split detail page for payee. Aditionally, the avatar is also wrong for payee.

What is the root cause of that problem?

The participants in SplitBillDetailsPage use the function below to fetch participants which are then filtered to get payeePersonalDetails and participantsExcludingPayee. As you can see, we set text to displayName here but the key displayName is not part of object that is returned. https://github.com/Expensify/App/blob/2a1c36d5bea964ee92ebfad11f92d8a22bbb7e4c/src/libs/OptionsListUtils.js#L213-L232 These are passed to MoneyRequestConfirmationList in SplitBillDetailsPage - https://github.com/Expensify/App/blob/fa5e5509d28123fe8676ef2749ad41900e0536b3/src/pages/iou/SplitBillDetailsPage.js#L84-L94

Now inside MoneyRequestConfirmationList, we use getIOUConfirmationOptionsFromPayeePersonalDetail for getting details of payee with amount, in line 813 we try to set displayName to text but displayName is not available as text was set to displayName in getParticipantsOptions line 218. So email is used as the fallback is personalDetail.login in line 813. https://github.com/Expensify/App/blob/2a1c36d5bea964ee92ebfad11f92d8a22bbb7e4c/src/libs/OptionsListUtils.js#L811-L825

It is correct for other participants, because for other participants, we use getIOUConfirmationOptionsFromParticipants which doesn't change participant and only adds amount - https://github.com/Expensify/App/blob/2a1c36d5bea964ee92ebfad11f92d8a22bbb7e4c/src/libs/OptionsListUtils.js#L834-L838

In OptionRow we show user name using fullTitle which is passed this.props.option.text which is wrong for payee - https://github.com/Expensify/App/blob/2a1c36d5bea964ee92ebfad11f92d8a22bbb7e4c/src/components/OptionRow.js#L211-L213

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

We should not change the personalDetail prop in getIOUConfirmationOptionsFromPayeePersonalDetail, instead we should follow the same approach followed in getIOUConfirmationOptionsFromParticipants and just add the amount in the field descriptiveText.

To follow DRY, we can - Change the function getIOUConfirmationOptionsFromPayeePersonalDetail to just return personalDetail object with a new field descriptiveText for amount. And then, we can reuse this function for participants. We can name this in a generic way so that it doesn't specify payee/participants.

function getIOUConfirmationOptionFromSingleParticipant(participant, amountText) {
    return {
        ...participant,
        descriptiveText: amountText,
    };
}

Now, we can use this function for payee and in getIOUConfirmationOptionsFromParticipants we can reuse the new function above.

What alternative solutions did you explore? (Optional)

NA

Before and after comparison Before - https://github.com/Expensify/App/assets/31413407/a425ed2e-0196-4538-bd86-1a4a67312498 After - https://github.com/Expensify/App/assets/31413407/718688a1-e5a3-4303-a2a5-0d2895a7e3a1
bernhardoj commented 1 year ago

This is a dupe of https://github.com/Expensify/App/issues/20118. There is already a PR going on to fix this

parasharrajat commented 1 year ago

Yes, it is a duplicate issue. We can close this. It was known to us so not eligible for reporting I guess.