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.57k stars 2.91k forks source link

Profile - Display Name Not Live Updated When Adding Legal Name to New Account #52900

Open IuliiaHerets opened 16 hours ago

IuliiaHerets commented 16 hours 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!


Version Number: v9.0.65-1 Reproducible in staging?: Y Reproducible in production?: Y Email or phone of affected tester (no customers): applausetester+tw33434343553@applause.expensifail.com Issue reported by: Applause Internal Team

Action Performed:

  1. Create a new account and navigate to Settings.
  2. Go to Profile, add a legal name, and observe that the Display Name is not updated.
  3. Refresh the page; the Display Name remains unchanged.

Expected Result:

When a legal name is added to a newly created account (or an account without a previously set display name), the Display Name should automatically inherit the legal name and update in real time.

Actual Result:

The Display Name does not update live after adding a legal name. It only updates after navigating back.

Workaround:

Unknown

Platforms:

Screenshots/Videos

https://github.com/user-attachments/assets/ee3cee57-2ad9-4a2d-86c2-cd780b3f6896

View all open jobs on GitHub

melvin-bot[bot] commented 16 hours ago

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

Themoonalsofall commented 16 hours ago

Edited by proposal-police: This proposal was edited at 2024-11-21 13:34:28 UTC.

Proposal

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

Profile - Display Name Not Live Updated When Adding Legal Name to New Account

What is the root cause of that problem?

When we call api updateLegalName we are not updating displayName in personalDetails Onyx

https://github.com/Expensify/App/blob/5955bd797eaaf60c2b02db95a35c18663d47effe/src/libs/actions/PersonalDetails.ts#L126-L135

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

We should update displayName in personalDetails Onyx base on legalFirstName, legalLastName when displayName is equal to login (default value) or we don't have both firstName and lastName

like BE is returning when we call OpenReport API

           {
                onyxMethod: Onyx.METHOD.MERGE,
                key: ONYXKEYS.PERSONAL_DETAILS_LIST,
                value: {
                    [currentUserAccountID]: {
                        displayName: PersonalDetailsUtils.createDisplayName(currentUserEmail ?? '', {
                            legalFirstName,
                            legalLastName,
                        }),
                    },
                },
            },

We can update field firstName and lastName too

What alternative solutions did you explore? (Optional)