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

[C+ checklist needs completion] [$500] Web - The display name doesn't show after logout and re-visit current page #28077

Closed
1 of 6 tasks
kbecciv opened this issue Sep 23, 2023 · 37 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

@kbecciv
Copy link

kbecciv commented Sep 23, 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!


Action Performed:

  1. Go to profile => Display name
  2. Copy current link then logout
  3. Login with copied link

Expected Result:

Display name should show

Actual Result:

Display name is empty

Workaround:

Unknown

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.73.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
Notes/Photos/Videos: Any additional supporting documentation

001.mp4
Recording.4727.mp4

Expensify/Expensify Issue URL:
Issue reported by: @suneox
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1695312629364939

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01dcb3033fb288e0ce
  • Upwork Job ID: 1705635806281445376
  • Last Price Increase: 2023-09-30
  • Automatic offers:
    • Ollyws | Reviewer | 27012099
    • suneox | Contributor | 27012100
@kbecciv kbecciv 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 Sep 23, 2023
@melvin-bot melvin-bot bot changed the title Web - The display name doesn't show after logout and re-visit current page [$500] Web - The display name doesn't show after logout and re-visit current page Sep 23, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 23, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 23, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 23, 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 melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 23, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 23, 2023

Triggered auto assignment to @greg-schroeder (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Sep 23, 2023

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

@kbecciv
Copy link
Author

kbecciv commented Sep 23, 2023

Proposal by: @suneox
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1695312629364939

Proposal

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

The display name doesn’t show after logout and re-visit current page

What is the root cause of that problem?

The user info load when on first time login via /api?command=OpenApp but the input defaultValue will get empty on the first time

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

At withCurrentUserPersonalDetails.js should get loading status with key ONYXKEYS.IS_LOADING_APP

    return withOnyx({
+       isLoading: {
+           key: ONYXKEYS.IS_LOADING_APP,
+       },
        personalDetails: {
            key: ONYXKEYS.PERSONAL_DETAILS_LIST,
        },
        session: {
            key: ONYXKEYS.SESSION,
        },
    })(withCurrentUserPersonalDetails);

also config propTypes and defaultProp for isLoading
Before render DisplayNamePage.js we will check isLoading status and return Loading component

    ...
+   if(props.isLoading) {
+       return <FullScreenLoadingIndicator />
+   }
    return (
      ...
    )

A lot of pages use withCurrentUserPersonalDetails so we should add isLoading status to aware using for the next feature or fix the issue with this

What alternative solutions did you explore? (Optional)

Create withCurrentUserPersonalDetailsAndLoadingState the same withCurrentUserPersonalDetails and same isLoading config from primary solution
before render WithCurrentUserPersonalDetails return Loading component

    function WithCurrentUserPersonalDetails(props) {
        const accountID = props.session.accountID;
        const accountPersonalDetails = props.personalDetails[accountID];
        const currentUserPersonalDetails = useMemo(() => ({...accountPersonalDetails, accountID}), [accountPersonalDetails, accountID]);
+       if (props.isLoading) {
+           return <FullScreenLoadingIndicator />;
+       }
        return (
            <WrappedComponent
                ...
            />
        );
    }

@saranshbalyan-1234
Copy link
Contributor

Proposal

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

display name doesn't show if page is visited via deeplink

What is the root cause of that problem?

The default value is not present by the time page renders.

defaultValue={lodashGet(currentUserDetails, 'firstName', '')}

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

We can maintain a name state and set this state everytime currentUserDetails changes, the solution would look something like this.

    const currentUserDetails = props.currentUserPersonalDetails || {};
    const [name, setName] = useState({firstName: lodashGet(currentUserDetails, 'firstName', ''), lastName: lodashGet(currentUserDetails, 'lastName', '')});
    useEffect(() => {
        if (!currentUserDetails) return;
        setName({firstName: lodashGet(currentUserDetails, 'firstName', ''), lastName: lodashGet(currentUserDetails, 'lastName', '')});
    }, [currentUserDetails]);

Now we can use this same state to get values in the component like this

   <TextInput
                        inputID="firstName"
                        name="fname"
                        label={props.translate('common.firstName')}
                        accessibilityLabel={props.translate('common.firstName')}
                        accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT}
                        defaultValue={lodashGet(name, 'firstName', '')}
                        maxLength={CONST.DISPLAY_NAME.MAX_LENGTH}
                        spellCheck={false}
                    />

and

  <TextInput
                        inputID="lastName"
                        name="lname"
                        label={props.translate('common.lastName')}
                        accessibilityLabel={props.translate('common.lastName')}
                        accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT}
                        defaultValue={lodashGet(name, 'lastName', '')}
                        maxLength={CONST.DISPLAY_NAME.MAX_LENGTH}
                        spellCheck={false}
                    />

What alternative solutions did you explore? (Optional)

N/A

@SergeyHTML
Copy link

SergeyHTML commented Sep 24, 2023

Proposal

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

display name doesn't show if the page is visited via a deep link

What is the root cause of that problem?

The default value is not present by the time page renders.

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

We can wrap inputs and check until we will not get data from BD.

defaultValue only gets set on the initial load for a form. After that, it won't get "naturally" updated because the intent was only to set an initial default value.

{currentUserDetails.displayName ? (
                  <>
                      <View style={styles.mb4}>
                          <TextInput
                            inputID="firstName"
                            name="fname"
                            label={props.translate('common.firstName')}
                            accessibilityLabel={props.translate('common.firstName')}
                            accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT}
                            defaultValue={lodashGet(currentUserDetails, 'firstName', '')}
                            maxLength={CONST.DISPLAY_NAME.MAX_LENGTH}
                            spellCheck={false}
                          />
                      </View>
                      <View>
                          <TextInput
                            inputID="lastName"
                            name="lname"
                            label={props.translate('common.lastName')}
                            accessibilityLabel={props.translate('common.lastName')}
                            accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT}
                            defaultValue={lodashGet(currentUserDetails, 'lastName', '')}
                            maxLength={CONST.DISPLAY_NAME.MAX_LENGTH}
                            spellCheck={false}
                          />
                      </View>
                  </>
                ) : <FullscreenLoadingIndicator style={[styles.flex1, styles.pRelative]} />}

What alternative solutions did you explore? (Optional)

We can use value instead of defaultValue. In this case, we also have to add the onChange method for updating the input value

Contributor details

Your Expensify account email: dubich.sv@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~0199b4b06f38ecd0fd

@melvin-bot
Copy link

melvin-bot bot commented Sep 24, 2023

📣 @SergeyHTML! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@SergeyHTML
Copy link

Contributor details

Your Expensify account email: dubich.sv@gmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~0199b4b06f38ecd0fd

@melvin-bot
Copy link

melvin-bot bot commented Sep 24, 2023

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@RichardPickman
Copy link

Contributor details
Your Expensify account email: real@richardpickman.com
Upwork Profile Link: https://www.upwork.com/freelancers/~0197f35da12754169c

@melvin-bot
Copy link

melvin-bot bot commented Sep 24, 2023

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@RichardPickman
Copy link

RichardPickman commented Sep 24, 2023

Proposal

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

firstName and lastName inputs doesn't rerender with fresh data coming from accountPersonalDetails

What is the root cause of that problem?

The default value is empty string, because at the first render data is unaccessible.

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

Move lodashGet(currentUserDetails, 'firstName', '') and lodashGet(currentUserDetails, 'lastName', '') to own variables to use them in <Form> key={} prop, to cause rerender, when data is updated

@lcsvcn
Copy link

lcsvcn commented Sep 25, 2023

IMPORTANT:
My Proposal was given Friday (22/09 - 15h30 UTC) over Slack.
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1695395915656879

Proposal

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

Display name fields are empty if accessed via deep link

What is the root cause of that problem?

The issue arises from the fact that the currentUserDetails.firstName and currentUserDetails.lastName are initialized with undefined. This delay in fetching the values can be easily fixed with a loading variable. Consequently, when the initial state is set, it is based on an empty JSON object because the actual values have not yet been retrieved. This results in incorrect initialization with empty values, which should ideally reflect the user's display name information.

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

I recommend adding a FullScreenLoading component, similar to the LegalNamePage.js:

<FullscreenLoadingIndicator style={[styles.flex1, styles.pRelative]} />

Then below the currentUserDetails initialization:
function DisplayNamePage(props) {
const currentUserDetails = props.currentUserPersonalDetails || {};

We add this function:

const [isLoadingDisplayName, setIsLoadingDisplayName] = useState(true);
useEffect(() => {
    setIsLoadingDisplayName(false);
    if (currentUserDetails.firstName === undefined || currentUserDetails.lastName === undefined) {
        setIsLoadingDisplayName(true);
    }
}, [currentUserDetails.lastName, currentUserDetails.firstName]);

With that, we guarantee that while the currentUserDetails isn't fetched with the fields necessary, we will display a loading, and as soon as it has valid value it will show the proper content, with updated info.

Video
fixed-display-name.mov

Here are my suggested changes for review

If my proposal is accepted, I can open a PR in a few hours to fix this. Thank you!

What alternative solutions did you explore? (Optional)

N/A

@greg-schroeder
Copy link
Contributor

Awaiting proposal review @Ollyws

@trjExpensify trjExpensify removed their assignment Sep 25, 2023
@suneox
Copy link
Contributor

suneox commented Sep 26, 2023

My proposal provided at 21/10 and I would like to update a minor proposal bellow

Proposal

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

The display name doesn't show after logout and re-visit current page

What is the root cause of that problem?

User info is loaded when the first time login via /api?command=OpenApp and the input defaultValue will get empty on the first time

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

At withCurrentUserPersonalDetails.js should get loading status with key ONYXKEYS.IS_LOADING_REPORT_DATA or ONYXKEYS.IS_LOADING_APP

    return withOnyx({
+       isLoading: {
+           key: ONYXKEYS.IS_LOADING_REPORT_DATA, // or ONYXKEYS.IS_LOADING_APP
+       },
        personalDetails: {
            key: ONYXKEYS.PERSONAL_DETAILS_LIST,
        },
        session: {
            key: ONYXKEYS.SESSION,
        },
    })(withCurrentUserPersonalDetails);

also config propTypes and defaultProp for isLoading
Before render DisplayNamePage.js we will check isLoading status and return Loading component

    ...
+   if(props.isLoading) {
+       return <FullScreenLoadingIndicator />
+   }

    return (
      ...
    )

or

{isLoading ? <FullScreenLoadingIndicator style={[styles.flex1, styles.pRelative]} /> : <FormProvider ...  />}

A lot of pages use withCurrentUserPersonalDetails so we should add isLoading status into withCurrentUserPersonalDetails.js to be aware of using it for the next feature or fix issues the same with this

What alternative solutions did you explore? (Optional)

Create withCurrentUserPersonalDetailsAndLoadingState the same withCurrentUserPersonalDetails and the same isLoading config from primary solution
before render WithCurrentUserPersonalDetails return Loading component

    function WithCurrentUserPersonalDetails(props) {
        const accountID = props.session.accountID;
        const accountPersonalDetails = props.personalDetails[accountID];
        const currentUserPersonalDetails = useMemo(() => ({...accountPersonalDetails, accountID}), [accountPersonalDetails, accountID]);
+       if (props.isLoading) {
+           return <FullScreenLoadingIndicator />;
+       }
        return (
            <WrappedComponent
                ...
            />
        );
    }

We apply this change to make it consistent with withPolicyAndFullscreenLoading is also using on a lot of page

@melvin-bot melvin-bot bot added the Overdue label Sep 27, 2023
@Ollyws
Copy link
Contributor

Ollyws commented Sep 27, 2023

Will review asap.

@melvin-bot
Copy link

melvin-bot bot commented Oct 4, 2023

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

@melvin-bot melvin-bot bot added the Overdue label Oct 4, 2023
@greg-schroeder
Copy link
Contributor

just waiting on @thienlnam to approve!

@melvin-bot melvin-bot bot removed the Overdue label Oct 4, 2023
@suneox
Copy link
Contributor

suneox commented Oct 4, 2023

Thank @thienlnam and @Ollyws I have accepted an offer and will create PR within today

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Oct 4, 2023
@suneox
Copy link
Contributor

suneox commented Oct 4, 2023

Hi, @Ollyws The PR is ready for review. Could you please help me review the PR? Thank you

@melvin-bot
Copy link

melvin-bot bot commented Oct 6, 2023

🎯 ⚡️ Woah @Ollyws / @suneox, great job pushing this forwards! ⚡️

The pull request got merged within 3 working days of assignment, so this job is eligible for a 50% #urgency bonus 🎉

  • when @suneox got assigned: 2023-10-04 05:39:14 Z
  • when the PR got merged: 2023-10-06 10:40:37 UTC

On to the next one 🚀

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 11, 2023
@melvin-bot melvin-bot bot changed the title [$500] Web - The display name doesn't show after logout and re-visit current page [HOLD for payment 2023-10-18] [$500] Web - The display name doesn't show after logout and re-visit current page Oct 11, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 11, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 11, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 11, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.80-3 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-10-18. 🎊

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:

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Oct 11, 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:

  • [@Ollyws] The PR that introduced the bug has been identified. Link to the PR:
  • [@Ollyws] 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:
  • [@Ollyws] 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:
  • [@Ollyws] Determine if we should create a regression test for this bug.
  • [@Ollyws] 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.
  • [@greg-schroeder] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Oct 17, 2023
@greg-schroeder
Copy link
Contributor

Processing

@greg-schroeder
Copy link
Contributor

Issue Participants:

Issue reported by: @suneox
Contributor: @suneox
C+: @Ollyws

Was this issue merged in time to be eligible for the speed bonus? yes
Were their any regressions? no

Payment summary:

Reporter: $50
Contributor: $750
C+: $750

@greg-schroeder greg-schroeder changed the title [HOLD for payment 2023-10-18] [$500] Web - The display name doesn't show after logout and re-visit current page [C+ checklist needs completion] [$500] Web - The display name doesn't show after logout and re-visit current page Oct 18, 2023
@greg-schroeder
Copy link
Contributor

Payment complete - just need to do the checklist and we can close this out @Ollyws!

@Ollyws
Copy link
Contributor

Ollyws commented Oct 18, 2023

BugZero Checklist:
This seems to have been present since the first implementation of DisplayNamePage in #12142 so I don't think we can really call it a regression.
Deep linking to the display name page is pretty edge case and doesn't really affect any important flows so I don't think a regression test is useful for this one.

@greg-schroeder
Copy link
Contributor

Thanks @Ollyws. Closing, then.

@suneox
Copy link
Contributor

suneox commented Oct 19, 2023

Thank @Ollyws @greg-schroeder so much I have received payment

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

10 participants