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

The "I accept the Expensify Terms of Service" checkbox not checked when retuning from step 2 #20871

Closed
2 of 6 tasks
kbecciv opened this issue Jun 15, 2023 · 6 comments
Closed
2 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2

Comments

@kbecciv
Copy link

kbecciv commented Jun 15, 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 Settings > Workspaces > Bank account > Connect manually
  2. Checked the checkbox first time
  3. Click on "Continue"
  4. After that return back to step 1(here you will see checkbox unchecked)
  5. Now again continue without checking the checkbox

Expected Result:

The "I accept the Expensify Terms of Service" checkbox should be checked after returning from step 2 and should displayed error message if unchecked

Actual Result:

The "I accept the Expensify Terms of Service" checkbox not checked when retuning from step 2 and not throwing an error

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

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

Notes/Photos/Videos: Any additional supporting documentation

2023-06-06.13-19-09.mp4
Recording.3131.mp4

Expensify/Expensify Issue URL:

Issue reported by: @ayazhussain79

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

View all open jobs on GitHub

@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 15, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 15, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jun 15, 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

@allroundexperts
Copy link
Contributor

Proposal

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

The checkbox values are not retained when returning back to the previous step.

What is the root cause of that problem?

The root cause of this issue is that we're using two props to determine if the checkbox is checked. We're using isChecked and value prop. The value prop is set by the Form here.
For the case mentioned in this bug, the value is set as true by the Form but the isChecked prop is false. On the first mount, the state value is true initially but after this effect runs, the state value becomes false, thus causing the checkbox to be unchecked.

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

The simplest way to fix this is to change defaultProp value of the value to be undefined instead of false. Then in the effect here, we can add the following:

if (props.value  !==  undefined) return;

What alternative solutions did you explore? (Optional)

We can also remove isChecked prop altogether and just use value everywhere. Likewise, we can also change the Form component, such that for checkboxes, it sets isChecked prop instead of the value prop here.

@hungvu193
Copy link
Contributor

hungvu193 commented Jun 16, 2023

Proposal

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

The "I accept the Expensify Terms of Service" checkbox not checked when retuning from step 2

What is the root cause of that problem?

I agree with Sibtain's proposal about the root cause of this issue is about the code inside CheckboxWithLabel:

useEffect(() => {
setIsChecked(props.isChecked);
}, [props.isChecked]);

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

Since isChecked is a state, it won't re-calculated when the props.value change, we should do it dynamically

const [isChecked, setIsChecked] = useState(_.find([props.value, props.defaultValue, props.isChecked], (value) => _.isBoolean(value)));

So our useEffect inside CheckboxWithLabel will look like this:

// we should update the checkbox value when props.value is changed, because our isChecked state isn't re-calculated
    useEffect(() => {
        setIsChecked(props.isChecked || props.value);
    }, [props.isChecked,  props.value]);

What alternative solutions did you explore? (Optional)

N/A

@bernhardoj
Copy link
Contributor

It's fixed in this PR #20091

@melvin-bot melvin-bot bot added the Overdue label Jun 19, 2023
@luacmartins luacmartins self-assigned this Jun 19, 2023
@luacmartins
Copy link
Contributor

I agree has already been fixed in my PR. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2
Projects
None yet
Development

No branches or pull requests

6 participants