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-02-15] [$1000] Settings - Changed name is not saved under Display name page #14784

Closed
6 tasks done
kbecciv opened this issue Feb 3, 2023 · 63 comments
Closed
6 tasks done
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 Feb 3, 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. Access staging.new.expensify.com
  2. Sign into a valid account
  3. Click on >Setting>Profile > Display name
  4. Change name>Click Save
  5. Click the back arrow
  6. Click the Display name again
  7. The new name does not match the old name

Expected Result:

Changed name is saved under Display name page

Actual Result:

Changed name is not saved under Display name page.

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.2.64.3

Reproducible in staging?: Yes

Reproducible in production?: No

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

Bug5922983_Recording__1974.mp4

Expensify/Expensify Issue URL:

Issue reported by: Applause - Internal Team & @priya-zha per #14773 (comment)

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01bc1f33f46287e85e
  • Upwork Job ID: 1621400923786579968
  • Last Price Increase: 2023-02-03
@kbecciv kbecciv added DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Feb 3, 2023
@melvin-bot
Copy link

melvin-bot bot commented Feb 3, 2023

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

@melvin-bot melvin-bot bot locked and limited conversation to collaborators Feb 3, 2023
@kbecciv
Copy link
Author

kbecciv commented Feb 3, 2023

Issue is not reproduced in Production

Recording.1976.mp4

@Christinadobrzyn
Copy link
Contributor

Christinadobrzyn commented Feb 3, 2023

I can repeat this in staging on MacOS / Chrome / Safari following these steps (I updated the OP with these steps)

  1. Access staging.new.expensify.com
  2. Sign into a valid account
  3. Click on > Setting > Profile > Display name
  4. Change name > Click Save
  5. Click the back arrow
  6. Click the Display name again
  7. The new name does not match the old name

2023-02-03_14-39-26 (1)

@Christinadobrzyn Christinadobrzyn added the External Added to denote the issue can be worked on by a contributor label Feb 3, 2023
@melvin-bot melvin-bot bot unlocked this conversation Feb 3, 2023
@melvin-bot melvin-bot bot changed the title Settings - Changed name is not saved under Display name page [$1000] Settings - Changed name is not saved under Display name page Feb 3, 2023
@melvin-bot
Copy link

melvin-bot bot commented Feb 3, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Feb 3, 2023

Current assignee @Christinadobrzyn is eligible for the External assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Feb 3, 2023

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

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

melvin-bot bot commented Feb 3, 2023

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

@Christinadobrzyn
Copy link
Contributor

Reading over our documentation, I don't know if external contributors can fix deploy blockers? @techievivek so you know?

Asking the team here

@sobitneupane
Copy link
Contributor

This is not limited to Profile Page Display Name only. I can reproduce the same issue on Workspace> General Settings> Name.

It is not limited to TextInput only. I can reproduce the same issue on <Picker /> as well (Workspace > General Settings > Default currency).

@sobitneupane
Copy link
Contributor

Change in the following line in #13501 PR has caused this regression.

inputValues: this.props.draftValues,

It used to be:

inputValues: {},

@tienifr
Copy link
Contributor

tienifr commented Feb 3, 2023

Proposal

Problem

As @sobitneupane mentioned above, the root cause is inputValues: this.props.draftValues. It's reference type

In https://github.com/tienifr/App/blob/8f754df0ddea4249eb5d1f94ea6642a8a797d08c/src/components/Form.js#L239
we update this.state.inputValues[inputID] = defaultValue, that makes this.props.draftValues change too.
In this case at first draftValues is empty object and we assign inputValues = draftValues (reference type), if inputValue is undefined we update this.state.inputValues[inputID] = defaultValue; => draftValues is updated to equal defaultValues too. That why when we open the display name form again, the input contains the stale defaultValues

Solution 1

        this.state = {
            errors: {},
-            inputValues: props.draftValues,
+             inputValues: {
+                ...props.draftValues
+            },
        };

Solution 2

I use lodashCloneDeep to clone the new draft object. That can make sure props.draftValues can't be change unexpectedly

...
+import lodashCloneDeep from 'lodash/cloneDeep';
...
        this.state = {
            errors: {},
-            inputValues: props.draftValues,
+            inputValues: lodashCloneDeep(props.draftValues)
        };

Result

Screen.Recording.2023-02-03.at.15.10.51.mov

@rushatgabhane
Copy link
Member

rushatgabhane commented Feb 10, 2023

What should be the next steps? @techievivek @sobitneupane @Christinadobrzyn

@melvin-bot melvin-bot bot added the Reviewing Has a PR in review label Feb 10, 2023
@Beamanator
Copy link
Contributor

@rushatgabhane normally the next steps would be for the PR author (@tienifr ) to fix the regression, but it looks like there's some other proposals on the linked issue? I don't see any "approved / accepted" proposals though

@techievivek
Copy link
Contributor

Can we ask @tienifr to look into the regression and fix it before we go with any new proposals?

@Beamanator
Copy link
Contributor

Makes sense to me!

@tienifr
Copy link
Contributor

tienifr commented Feb 10, 2023

@Beamanator @techievivek Thank for your feedback, but In

<CheckboxWithLabel
style={styles.mt4}
inputID="acceptedTerms"
LabelComponent={() => (
<Text>
{this.props.translate('common.iAcceptThe')}
<TextLink
href="https://use.expensify.com/terms"
// to call the onPress in the TextLink before the input blur is fired and shift the link element
onMouseDown={e => e.preventDefault()}
>
{`Expensify ${this.props.translate('common.termsOfService')}`}
</TextLink>
</Text>
)}
defaultValue={this.props.getDefaultStateForField('acceptTerms', false)}
shouldSaveDraft
/>

we use two different names: acceptedTerms for inputID but we get acceptTerms from defaultState
So my suggestion is to change this line
defaultValue={this.props.getDefaultStateForField('acceptTerms', false)}

to

defaultValue={this.props.getDefaultStateForField('acceptedTerms', false)}

My result after applying this change:

Screen.Recording.2023-02-10.at.15.14.17.mov

@tienifr
Copy link
Contributor

tienifr commented Feb 10, 2023

But I'm not sure this problem comes from my PR, or we should create other issue for this? Thanks.

@Beamanator
Copy link
Contributor

@rushatgabhane huh if the problem is that the inputIDs are not matching, why are we thinking the PR for this issue caused the regression? 😅

@fedirjh
Copy link
Contributor

fedirjh commented Feb 10, 2023

@rushatgabhane huh if the problem is that the inputIDs are not matching, why are we thinking the PR for this issue caused the regression? 😅

@Beamanator that's not the problem. I have posted an explanation in the other issue. #14972 (comment)

@tienifr acceptTerms is returned from the server and we use it to initialize the defaultValue . However the Form is not using the defaultValue and instead uses draftValue

@tienifr
Copy link
Contributor

tienifr commented Feb 13, 2023

I think the problem here is so simple and my PR doesn't cause the regression. We should keep the preceded PR #13501 because it's complex implementation and works well. This is normal if there're some minor issues when we release the new feature. So I pushed the proposal here: #14972 (comment).

@rushatgabhane
Copy link
Member

rushatgabhane commented Feb 13, 2023

@Beamanator yeah my bad 😅
https://github.com/Expensify/App/pull/14866/files isn't causing the regression (can be verified by reverting the PR). Sorry for the trouble

@Beamanator
Copy link
Contributor

Okkkkk great good to know, thanks for the investigation @rushatgabhane ! No trouble at all 🙏

@Beamanator
Copy link
Contributor

Beamanator commented Feb 13, 2023

@rushatgabhane looks like you will continue reviewing proposals for the other issue (#14972) over there so I believe this PR can be payed out, right? (in 2 days, i guess)

@Beamanator Beamanator removed the Reviewing Has a PR in review label Feb 13, 2023
@fedirjh
Copy link
Contributor

fedirjh commented Feb 13, 2023

We should keep the preceded PR #13501 because it's complex implementation and works well.

No, we should not continue using incorrect patterns just to avoid a bug. In #13501, consistency should have been maintained by using the proper pattern. Instead of passing draftValue down from the Form, it would have been better to subscribe to draftValues with Onyx.

In other components, this is the pattern that we use to retrieve the draftValues.

reimbursementAccountDraft: {
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT_DRAFT,
},

@Christinadobrzyn
Copy link
Contributor

Hi! Just checking on this, @techievivek @Beamanator @fedirjh @tienifr are we waiting on #14972 before issuing payment on this job?

@Beamanator
Copy link
Contributor

Beamanator commented Feb 15, 2023

My understanding is that the other issue (#14972) is unrelated to the fix in this issue. The fix in this issue (#14866) was merely fixing a bug from #13501, so if anything the regression #14972 would have been caused by #13501

So my understanding is we are good to pay this one out, but @rushatgabhane and @fedirjh should continue discussing and investigating a solid fix for #14972 in that issue - I like the discussion, but I don't think it belongs here anymore as this fix was very small, and it tests well.

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Feb 15, 2023
@techievivek
Copy link
Contributor

@Beamanator Hi, can you confirm if @sobitneupane would receive a 50% bonus as the PR was merged within 3 business days?

@Christinadobrzyn
Copy link
Contributor

Yes, my understanding is the Contributor and C+ both get the bonus if the PR is merged within 3 days.

I think we just need to finalise this BuzZero checklist

#14784 (comment)

@Beamanator
Copy link
Contributor

Makes sense to me @Christinadobrzyn and @techievivek 👍

@rushatgabhane
Copy link
Member

so I believe this PR can be payed out, right

yes yes

@Christinadobrzyn
Copy link
Contributor

@sobitneupane @tienifr can you please complete this checklist so we can close this out?

#14784 (comment)

@sobitneupane
Copy link
Contributor

sobitneupane commented Feb 20, 2023

The PR that introduced the bug has been identified. Link to the PR:

#13501

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:

https://github.com/Expensify/App/pull/13501/files#r1111477927

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:

https://expensify.slack.com/archives/C049HHMV9SM/p1676872397051299

@tienifr
Copy link
Contributor

tienifr commented Feb 20, 2023

@Christinadobrzyn if you mean the regression test step, it was already added here #14784 (comment)

@Christinadobrzyn
Copy link
Contributor

Christinadobrzyn commented Feb 21, 2023

Ah thank you @tienifr I missed that. Proposed Regression Test here - https://expensify.slack.com/archives/C01SKUP7QR0/p1676967958834629

@tienifr Should the below Regression Test steps be part of this GH instead?

  • Verify the form refactor for ACH Contract Step of Add Bank Account form works expectedly
  • Go to Setting > Workspace > Connect bank account > Connect manually
  • Fill the form and go to step 4
  • Check "Somebody else owns more than 25% of" and filling out the Identity Form part way
  • Refresh the page to ensure that the checkbox is still checked and the identify form is rendered with the values you entered

@Christinadobrzyn
Copy link
Contributor

I think this can be closed so I'm going to close it but let me know if it needs to remain open for anything

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