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 2023-11-13] [$500] Chat - After creating a money request, email are first displayed, then changed to set name #30456

Closed
3 of 6 tasks
lanitochka17 opened this issue Oct 26, 2023 · 29 comments
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 Oct 26, 2023

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.91-6
Reproducible in staging?: Yes
Reproducible in production?: Yes
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:

Action Performed:

  1. Go to URL https://staging.new.expensify.com/
  2. Login with any account
  3. Go to FAB -> Request money -> Manually -> Use an account with set user name -> Request

Expected Result:

The immediately installed username is displayed at the top of the page

Actual Result:

At the top of the page, first, the email is displayed, and then it changes to the set username

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
  • MacOS: Desktop

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Bug6252081_1698337680025.Recording__6558.mp4
MacOS: Desktop

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01ef7eaea70e5f02e1
  • Upwork Job ID: 1717582124675444736
  • Last Price Increase: 2023-10-26
  • Automatic offers:
    • s77rt | Reviewer | 27438378
    • bernhardoj | Contributor | 27438383
@lanitochka17 lanitochka17 added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 26, 2023
@melvin-bot melvin-bot bot changed the title Chat - After creating a money request, email are first displayed, then changed to set name [$500] Chat - After creating a money request, email are first displayed, then changed to set name Oct 26, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 26, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 26, 2023

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 26, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 26, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 26, 2023

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

@peymancyb
Copy link

I am checking this issue 👀

@cooldev900
Copy link
Contributor

cooldev900 commented Oct 27, 2023

Proposal

from: @cooldev900

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

After creating a money request, email are first displayed, then changed to set name in LHN.

What is the root cause of that problem?

The root cause is because it returns displayName at the first time after creating a money request instead of firstname and lastname.
At that time, the displayName in allPersonalDetails[accountID] Object is an email address that represents user's login content.

image

App/src/libs/ReportUtils.js

Lines 1175 to 1179 in cb5aeb1

return (
(allPersonalDetails && allPersonalDetails[accountID]) || {
avatar: UserUtils.getDefaultAvatar(accountID),
}
);

App/src/libs/ReportUtils.js

Lines 1189 to 1197 in cb5aeb1

function getDisplayNameForParticipant(accountID, shouldUseShortForm = false) {
if (!accountID) {
return '';
}
const personalDetails = getPersonalDetailsForAccountID(accountID);
const longName = personalDetails.displayName;
const shortName = personalDetails.firstName || longName;
return shouldUseShortForm ? shortName : longName;
}

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

So we need to check if the personalDetail includes firstName and lastNae and if it doesn't include, we can return displayName.

function getDisplayNameForParticipant(accountID, shouldUseShortForm = false) {
    if (!accountID) {
        return '';
    }
    const personalDetails = getPersonalDetailsForAccountID(accountID);
    const shortName = personalDetails.firstName || personalDetails.lastName || personalDetails.displayName || '';
    const longName = personalDetails.firstName ||  personalDetails.lastName ? `${personalDetails.firstName || ''} ${personalDetails.lastName || ''}` : personalDetails.displayName || ''
    return shouldUseShortForm ? shortName : longName;
}

What alternative solutions did you explore? (Optional)

If we don't want to change getDisplayNameForParticipant function, the backend should return correct displayName that include firstName and lastName in personalDetail. And we need to sync personalDetails data to backend when selecting participants in requesting money and also other user selection cases.

Result

Video_2023-10-26_215420-mac-chrome_20231026215533.mp4

@s77rt
Copy link
Contributor

s77rt commented Oct 27, 2023

@cooldev900 Thanks for the proposal. I don't think your RCA is correct. From what I can tell and based on the attached screenshot, we re-creating the personalDetails item object even though we have it. And by doing so we are overwriting the displayName field. Can you please recheck if that's the case?

@cooldev900
Copy link
Contributor

cooldev900 commented Oct 27, 2023

@s77rt
Yes, you are right. The personalDetails item object is updated, but it takes some time to update, so initially the LHN displays the title using existing personalDetails item (including email) and then when updated, it displays the updated content again(firstName and lastName). That's why we can see two different titles in LHN within for a short period of time.

@s77rt
Copy link
Contributor

s77rt commented Oct 27, 2023

@cooldev900 That's not what I meant. This is the flow:

  1. personal details is holding the correct displayName (firstname lastname)
  2. after making a money request, personal detaills' displayName is overwritten (email@test.com)
  3. later the displayName is corrected from the backend (firstname lastname)

The bug is on step 2, which means that the bug is on the frontend and not the backend..

@cooldev900
Copy link
Contributor

oh, let me re-check now.

@cooldev900
Copy link
Contributor

It is personalDetails item before requesting money.

{
    "A15929525": {
        "accountID": 15929525,
        "avatar": "https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_13.png",
        "displayName": "Name Name",
        "firstName": "Name",
        "lastName": "Name",
        "login": "ca19901101+test04@gmail.com",
        "pronouns": "",
        "timezone": {
            "automatic": true,
            "selected": "America/Chicago"
        },
        "payPalMeAddress": "",
        "phoneNumber": "",
        "validated": true
    },
    "P15929525": {
        "accountID": 15929525,
        "login": "ca19901101+test04@gmail.com",
        "displayName": "Name Name",
        "firstName": "Name"
    }
}

It is one right after requesting money.

{
    "A15929525": {
        "accountID": 15929525,
        "avatar": "https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_6.png",
        "displayName": "ca19901101+test04@gmail.com",
        "firstName": "Name",
        "lastName": "Name",
        "login": "ca19901101+test04@gmail.com",
        "pronouns": "",
        "timezone": {
            "automatic": true,
            "selected": "America/Chicago"
        },
        "payPalMeAddress": "",
        "phoneNumber": "",
        "validated": true,
        "isOptimisticPersonalDetail": true
    },
    "P15929525": {
        "accountID": 15929525,
        "login": "ca19901101+test04@gmail.com",
        "displayName": "ca19901101+test04@gmail.com",
        "firstName": "Name"
    }
}
{
    "A15929525": {
        "accountID": 15929525,
        "avatar": "https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_13.png",
        "displayName": "Name Name",
        "firstName": "Name",
        "lastName": "Name",
        "login": "ca19901101+test04@gmail.com",
        "pronouns": "",
        "timezone": {
            "automatic": true,
            "selected": "America/Chicago"
        },
        "payPalMeAddress": "",
        "phoneNumber": "",
        "validated": true,
        "isOptimisticPersonalDetail": true
    },
    "P15929525": {
        "accountID": 15929525,
        "login": "ca19901101+test04@gmail.com",
        "displayName": "Name Name",
        "firstName": "Name"
    }
}

We are overwriting displayName twice after requesting money.

@s77rt
Copy link
Contributor

s77rt commented Oct 27, 2023

@cooldev900 Can you please update your proposal fixing this issue?

@cooldev900
Copy link
Contributor

Yes, I am doing.

@cooldev900
Copy link
Contributor

cooldev900 commented Oct 27, 2023

Proposal

from: @cooldev900

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

After creating a money request, email are first displayed, then changed to set name in LHN.

What is the root cause of that problem?

The root cause is because we didn't set displayName in participant object so that displayName is set to payerEmail in optimisticPersonalDetailListAction.

displayName: LocalePhoneNumber.formatPhoneNumber(participant.displayName || payerEmail),

return isPolicyExpenseChat ? OptionsListUtils.getPolicyExpenseReportOption(participant) : OptionsListUtils.getParticipantsOption(participant, props.personalDetails);

function getParticipantsOption(participant, personalDetails) {
const detail = getPersonalDetailsForAccountIDs([participant.accountID], personalDetails)[participant.accountID];
const login = detail.login || participant.login;
const displayName = detail.displayName || LocalePhoneNumber.formatPhoneNumber(login);
return {
keyForList: String(detail.accountID),
login,
accountID: detail.accountID,
text: displayName,
firstName: lodashGet(detail, 'firstName', ''),
lastName: lodashGet(detail, 'lastName', ''),
alternateText: LocalePhoneNumber.formatPhoneNumber(login) || displayName,
icons: [
{
source: UserUtils.getAvatar(detail.avatar, detail.accountID),
name: login,
type: CONST.ICON_TYPE_AVATAR,
id: detail.accountID,
},
],
phoneNumber: lodashGet(detail, 'phoneNumber', ''),
selected: participant.selected,
searchText: participant.searchText,
};
}

function getPolicyExpenseReportOption(report) {
const expenseReport = policyExpenseReports[`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`];
const option = createOption(
expenseReport.participantAccountIDs,
allPersonalDetails,
expenseReport,
{},
{
showChatPreviewLine: false,
forcePolicyNamePreview: false,
},
);
// Update text & alternateText because createOption returns workspace name only if report is owned by the user
option.text = ReportUtils.getPolicyName(expenseReport);
option.alternateText = Localize.translateLocal('workspace.common.workspace');
option.selected = report.selected;
return option;
}

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

So we need to create displayName property in both getPolicyExpenseReportOption and getParticipantsOption.

function getParticipantsOption(participant, personalDetails) {
    const detail = getPersonalDetailsForAccountIDs([participant.accountID], personalDetails)[participant.accountID];
    const login = detail.login || participant.login;
    const displayName = detail.displayName || LocalePhoneNumber.formatPhoneNumber(login);
    console.log({participant, displayName, detail})
    return {
        keyForList: String(detail.accountID),
        login,
        accountID: detail.accountID,
        text: displayName,
        displayName: displayName,
        firstName: lodashGet(detail, 'firstName', ''),
        lastName: lodashGet(detail, 'lastName', ''),
        alternateText: LocalePhoneNumber.formatPhoneNumber(login) || displayName,
        icons: [
            {
                source: UserUtils.getAvatar(detail.avatar, detail.accountID),
                name: login,
                type: CONST.ICON_TYPE_AVATAR,
                id: detail.accountID,
            },
        ],
        phoneNumber: lodashGet(detail, 'phoneNumber', ''),
        selected: participant.selected,
        searchText: participant.searchText,
    };
}

function getPolicyExpenseReportOption(report) {
    const expenseReport = policyExpenseReports[`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`];

    const option = createOption(
        expenseReport.participantAccountIDs,
        allPersonalDetails,
        expenseReport,
        {},
        {
            showChatPreviewLine: false,
            forcePolicyNamePreview: false,
        },
    );

    // Update text & alternateText because createOption returns workspace name only if report is owned by the user
    option.text = ReportUtils.getPolicyName(expenseReport); 
    if (!option.displayName) option.displayName = ReportUtils.getPolicyName(expenseReport);
    option.alternateText = Localize.translateLocal('workspace.common.workspace');
    option.selected = report.selected;
    return option;
}

What alternative solutions did you explore? (Optional)

We could change displayName to text here.

const optimisticPersonalDetailListAction = isNewChatReport
        ? {
              [payerAccountID]: {
                  accountID: payerAccountID,
                  avatar: UserUtils.getDefaultAvatarURL(payerAccountID),
                  displayName: LocalePhoneNumber.formatPhoneNumber(participant.text || payerEmail),
                  login: participant.login,
                  isOptimisticPersonalDetail: true,
              },
          }
        : undefined;

@bernhardoj
Copy link
Contributor

Same issue as #25927 which gets closed, so I copied my proposal from there.

Proposal

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

When we request money with a user we never chatted before with a display name but we have their contact (personal detail), their display name will be changed to their login. I can only reproduce this case on a high-traffic account where we have other user accounts without ever chatting with them.

What is the root cause of that problem?

When we make a money request, we check if we should create an optimistic personal detail.

App/src/libs/actions/IOU.js

Lines 559 to 570 in a59d56f

// Add optimistic personal details for participant
const optimisticPersonalDetailListAction = isNewChatReport
? {
[payerAccountID]: {
accountID: payerAccountID,
avatar: UserUtils.getDefaultAvatarURL(payerAccountID),
displayName: LocalePhoneNumber.formatPhoneNumber(participant.displayName || payerEmail),
login: participant.login,
isOptimisticPersonalDetail: true,
},
}
: undefined;

isNewChatReport is true if there is no chat/report found with the selected participant. In cases where we already have the user's personal details but not the report, it will override the existing personal details with the optimistic detail. That's why after the request, the avatar and display name are changed.

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

I don't know if there will be a real case where we have the user's personal details but not their report/chat.

Instead of checking whether we have a report/chat with the user, we can check if we already have the user's personal details.

!allPersonalDetails[payerAccountID] ? optimisticPersonalDetails : undefined

Just like what we did in IOU.startSplitBill

App/src/libs/actions/IOU.js

Lines 1471 to 1486 in a59d56f

const participantPersonalDetails = allPersonalDetails[participant.accountID];
if (!participantPersonalDetails) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
value: {
[accountID]: {
accountID,
avatar: UserUtils.getDefaultAvatarURL(accountID),
displayName: LocalePhoneNumber.formatPhoneNumber(participant.displayName || email),
login: participant.login || participant.text,
isOptimisticPersonalDetail: true,
},
},
});
}

@s77rt
Copy link
Contributor

s77rt commented Oct 28, 2023

@cooldev900 Thanks for the update. I still don't think your RCA is correct. The root cause is the displayName being overwritten in the first place.

For future proposal please don't write a new comment but instead update the existing one.

@s77rt
Copy link
Contributor

s77rt commented Oct 28, 2023

@bernhardoj Thanks for the proposal. Your RCA is correct. The solution looks good to me but we can keep the isNewChatReport condition for consistency*.

*The other issue was fixed by #29279

🎀 👀 🎀 C+ reviewed
Link to proposal

@melvin-bot
Copy link

melvin-bot bot commented Oct 28, 2023

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

@melvin-bot melvin-bot bot added the Overdue label Oct 30, 2023
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 30, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 30, 2023

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

Offer link
Upwork job

@melvin-bot
Copy link

melvin-bot bot commented Oct 30, 2023

📣 @bernhardoj 🎉 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 📖

@grgia
Copy link
Contributor

grgia commented Oct 30, 2023

Thanks for the proposal @bernhardoj, all yours!

@bernhardoj
Copy link
Contributor

PR is ready

cc: @s77rt

Copy link

melvin-bot bot commented Nov 3, 2023

⚠️ 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.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Nov 6, 2023
@melvin-bot melvin-bot bot changed the title [$500] Chat - After creating a money request, email are first displayed, then changed to set name [HOLD for payment 2023-11-13] [$500] Chat - After creating a money request, email are first displayed, then changed to set name Nov 6, 2023
Copy link

melvin-bot bot commented Nov 6, 2023

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Nov 6, 2023
Copy link

melvin-bot bot commented Nov 6, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.95-9 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 2023-11-13. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Nov 6, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@s77rt] The PR that introduced the bug has been identified. Link to the PR:
  • [@s77rt] 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:
  • [@s77rt] A discussion in #expensify-bugs 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:
  • [@s77rt] Determine if we should create a regression test for this bug.
  • [@s77rt] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@conorpendergrast] Link the GH issue for creating/updating the regression test once above steps have been agreed upon: https://github.com/Expensify/Expensify/issues/336527

@s77rt
Copy link
Contributor

s77rt commented Nov 7, 2023


Regression Test Proposal

  1. Login with a HT account
  2. Request money from a user with a display name that you have not chatted with before
  3. Verify the user display name is displayed correctly (in the report header)

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 Daily KSv2 labels Nov 13, 2023
@conorpendergrast
Copy link
Contributor

Payouts due:

Issue Reporter: N/A - Applause

Upwork job is here.

@conorpendergrast
Copy link
Contributor

Regression test request created: https://github.com/Expensify/Expensify/issues/336527

All done, thanks everyone!

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
None yet
Development

No branches or pull requests

7 participants