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.48k stars 2.83k forks source link

[HOLD for payment 2023-06-30] [$2000] Web - Split - The unselected members are selected if you click on Amount field and return back (Works well if you click on description and return back) #17662

Closed kbecciv closed 1 year ago

kbecciv commented 1 year 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!


Action Performed:

  1. Go to web chrome
  2. Go to group chat with 3+ members
  3. Click on plus icon and click on split bill
  4. Input a number
  5. Click on save
  6. Remove any member from the list
  7. Now click on amount and Save
  8. Notice that the member you removed earlier is again selected
  9. But now , again remove any member and click on description and Save
  10. Notice that now the problem doesn't occur. The member you removed earlier is still not selected. Thus, the problem only occurs if you click on amount field.

Expected Result:

The removed member should not be selected on clicking amount field in a similar way how the removed member is not selected when clicked on the description

Actual Result:

The removed member is selected again if you click on amount field unlike the description field

Workaround:

Unknown

Platforms:

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

Version Number: 1.3.1.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

https://user-images.githubusercontent.com/93399543/233128095-cedee447-d483-4cfa-b683-d1d295a4279c.mp4

https://user-images.githubusercontent.com/93399543/233127965-d018d429-e9e6-444e-bd1c-e8b11ad80769.mp4

Expensify/Expensify Issue URL:

Issue reported by: @priya-zha

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~014c6f23446b0fe33b
  • Upwork Job ID: 1648965284444319744
  • Last Price Increase: 2023-07-03
MelvinBot commented 1 year ago

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

MelvinBot commented 1 year ago

Bug0 Triage Checklist (Main S/O)

conorpendergrast commented 1 year ago

Reproduced, thanks!

MelvinBot commented 1 year ago

Job added to Upwork: https://www.upwork.com/jobs/~014c6f23446b0fe33b

MelvinBot commented 1 year ago

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

MelvinBot commented 1 year ago

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

MelvinBot commented 1 year ago

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

dukenv0307 commented 1 year ago

Proposal

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

Web - Split - The unselected members are selected if you click on the Amount field and return back (Works well if you click on description and return back)

What is the root cause of that problem?

When the user clicks the amount and comes back, MoneyRequestConfirmationList Component will be unmounted when clicking the Amount field and then it will be mounted when the user comes back. So that all members will be selected by this logic https://github.com/Expensify/App/blob/1cd304c4d9871caa13362d76f1a8a11a940306b7/src/components/MoneyRequestConfirmationList.js#L88-L90 This problem does not happen when clicking the description and return back because when clicking the description, MoneyRequestConfirmationList Component will not be unmounted

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

We could create a new field splitBillParticipant_ReportID in ONYX and in /App/src/libs/actions/IOU.js we will create a new function to update this field when the user selects or unselects participants. In MoneyRequestConfirmationList Component we will not set all participants are selected like this https://github.com/Expensify/App/blob/1cd304c4d9871caa13362d76f1a8a11a940306b7/src/components/MoneyRequestConfirmationList.js#L88-L90 We will get splitBillParticipant_ReportID from ONYX and set selected field (true/ false) for all participants based on splitBillParticipant_ReportID

What alternative solutions did you explore? (Optional)

huzaifa-99 commented 1 year ago

Proposal

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

When we unselect a participant from spilt bill, then navigate to amount page and come back then the unselected participant is again selected.

What is the root cause of that problem?

We are not updating state when any participant is removed from the selected list

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

We should update the selected participants list whenever a participant is selected/unselected. I would suggest these changes

  1. Add a new prop onParticipantChange to MoneyRequestConfirmationList
  2. Trigger the new prop onParticipantChange in MoneyRequestConfirmationList whenever the state updates
    componentDidUpdate(prevProps,prevState) {
    if(!_.isEqual(this.state.participants, prevState.participants)) {
        this.props.onParticipantsChange(this.state.participants)
    }
    }
  3. Change how we set selected participants, currently it happens here like this
    const formattedParticipants = _.map(this.getParticipantsWithAmount(props.participants), participant => ({
    ...participant, selected: true,
    }));

    but we should do it like this (selected should be set first, and will be overridden if the participants array has the 'selected' field already set)

    const formattedParticipants = _.map(this.getParticipantsWithAmount(props.participants), participant => ({
    selected: true,
    ...participant, 
    }));
  4. Finally, we need to update our state here whenever the participants change
    onParticipantsChange={(updatedParticipants) => {
    setSelectedOptions([
        ..._.filter(selectedOptions, email => props.currentUserPersonalDetails.login === email.login),
        ...updatedParticipants,
    ])
    }}
Demo https://user-images.githubusercontent.com/68777211/233332872-2ac78f01-4743-4ca2-ab01-635421500b09.mov

What alternative solutions did you explore? (Optional)

N/A

bernhardoj commented 1 year ago

Proposal

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

All participants selected state is lost when we navigate to edit amount page.

What is the root cause of that problem?

We are rendering conditionally each screen (amount, participants, and confirmation), while the description screen is a separate stack screen. When we navigate from confirmation page to amount page, confirmation page will be unmount, thus the state (selected participants) is lost and everyone becomes selected again. https://github.com/Expensify/App/blob/1cd304c4d9871caa13362d76f1a8a11a940306b7/src/pages/iou/MoneyRequestModal.js#L414-L447

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

My solution is basically very similar with @huzaifa-99, but because I have spent my time finding the solution, I will still share it.

Currently, we store the selected participants as a state inside MoneyRequestConfirmationList. First step, we can introduce a new props called onParticipantsChange that will call setSelectedOptions to update the selected options/participants in MoneyRequestModal, so we don't need the state here anymore. We can also ignore the getParticipantsWithAmount because it's redundant. We already call it inside getSections https://github.com/Expensify/App/blob/1cd304c4d9871caa13362d76f1a8a11a940306b7/src/components/MoneyRequestConfirmationList.js#L88-L94 https://github.com/Expensify/App/blob/1cd304c4d9871caa13362d76f1a8a11a940306b7/src/components/MoneyRequestConfirmationList.js#L170-L171 We can also remove getParticipantsWithoutAmount because it won't do nothing anymore since participants won't have descriptiveText by default.

All this.state.participants will be replaced with this.props.participants.

To notify MoneyRequestModal the new participants, we won't need this setState anymore and we will call onParticipantsChange here. https://github.com/Expensify/App/blob/1cd304c4d9871caa13362d76f1a8a11a940306b7/src/components/MoneyRequestConfirmationList.js#L232-L240

Two last things left.

We can look here that we map the list and give it a selected value. We will need to do the same when we create the selectedOptions array here. https://github.com/Expensify/App/blob/1cd304c4d9871caa13362d76f1a8a11a940306b7/src/pages/iou/MoneyRequestModal.js#L118-L122

Last, we should reset all selected value back to true if the user navigate back from confirm page to amount page. amount -> confirm -> amount back, don't reset amount -> confirm back, reset

But it's currently not possible because we have this bug https://github.com/Expensify/App/issues/17637. So, we should fix that first before continue this.

What alternative solutions did you explore? (Optional)

Honestly, I think it would be much cleaner to have this 3 pages (amount, participants, confirmation) have their own stack screen. I don't know the reason why we put all these 3 "pages" inside MoneyRequestModal and manually handle the navigation, transition animation, etc. This will become harder to maintain as the component grows. IMO, it would be great if each of those pages have their own Stack.Screen, then we wrap it with a context provider to have a shared value such as the amount, participants, etc. If there are no special reasons to why we put those 3 "pages" in a single screen, I would be happy to do the refactor πŸ˜„

MelvinBot commented 1 year ago

Looks like something related to react-navigation may have been mentioned in this issue discussion.

As a reminder, please make sure that all proposals are not workarounds and that any and all attempt to fix the issue holistically have been made before proceeding with a solution. Proposals to change our DeprecatedCustomActions.js files should not be accepted.

Feel free to drop a note in #expensify-open-source with any questions.

thesahindia commented 1 year ago

Last, we should reset all selected value back to true if the user navigate back from confirm page to amount page. amount -> confirm -> amount back, don't reset amount -> confirm back, reset

Hmm, I am not sure about this. We don't clear the description text on the confirmation screen when going back to the amount page so I think we also shouldn't reset the selected value. Also I think it's pretty normal to use the back button when you wanna go back to edit something and it will not be a good experience to see that the changes you made are gone.

thesahindia commented 1 year ago

I prefer @bernhardoj's proposal more because of the code refactor.

πŸŽ€πŸ‘€πŸŽ€ C+ reviewed

cc: @PauloGasparSv

PauloGasparSv commented 1 year ago

I prefer @bernhardoj's https://github.com/Expensify/App/issues/17662#issuecomment-1516095431 more because of the code refactor.

I agree with you @thesahindia! So I'm assigning them here : )

But it's currently not possible because we have this bug https://github.com/Expensify/App/issues/17637. So, we should fix that first before continue this.

Hey @bernhardoj that's a great catch. Can this be worked in parallel while that other bug is fixed? I'm not 100% sure if we should put this on HOLD until that's fixed.

MelvinBot commented 1 year ago

πŸ“£ @bernhardoj You have been assigned to this job by @PauloGasparSv! Please apply to this job in Upwork 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 πŸ“–

thesahindia commented 1 year ago

@PauloGasparSv, what's your opinion about https://github.com/Expensify/App/issues/17662#issuecomment-1518071661

bernhardoj commented 1 year ago

As we agree to do the refactor, both of these issues https://github.com/Expensify/App/issues/17637 & https://github.com/Expensify/App/issues/17710 won't happen anymore after the refactor.

Hopefully we are on the same page on the refactoring πŸ˜„. I will open the PR soon!

bernhardoj commented 1 year ago

Ah, btw I agree with that https://github.com/Expensify/App/issues/17662#issuecomment-1518071661 as we also save description.

bernhardoj commented 1 year ago

I keep getting this lint error

Oops! Something went wrong! :(

ESLint: 7.32.0

TypeError: externalProps is not iterable (cannot read property undefined)
Occurred while linting /Users/bernhardoj/Documents/dev/freelance/Expensify/src/pages/iou/steps/MoneyRequestAmountPage.js:440
    at /Users/bernhardoj/Documents/dev/freelance/Expensify/node_modules/eslint-config-expensify/eslint-plugin-expensify/onyx-props-must-have-default.js:102:39

As it's EOD for me, I will continue to find the fix tomorrow!

s77rt commented 1 year ago

What's the state here, are we planing to refactor the request money modal? If so should we hold https://github.com/Expensify/App/issues/17710?

dukenv0307 commented 1 year ago

I think it would be better to get broader confirmation on whether to do the refactor, there might be conscious reason why it was designed this way to begin with.

bernhardoj commented 1 year ago

@s77rt yes, I think we can hold that, unless we cancel the refactor

@PauloGasparSv what do you think about @dukenv0307 comment here https://github.com/Expensify/App/issues/17662#issuecomment-1521165853

While waiting for the answer, I have open the PR for anyone who would like to see the refactor.

bernhardoj commented 1 year ago

@PauloGasparSv Bump on this https://github.com/Expensify/App/issues/17662#issuecomment-1521704246 as you previously already agreed with the refactor here https://github.com/Expensify/App/issues/17662#issuecomment-1520125938.

If it's not needed, I think @thesahindia can start reviewing the PR πŸ˜„.

thesahindia commented 1 year ago

Hi, I will be away for one or two days. I've made a post on the channel to check if anyone else would be willing to take care of this.

s77rt commented 1 year ago

I will take it!

thesahindia commented 1 year ago

Thanks @s77rt! @PauloGasparSv, please assign @s77rt here.

MelvinBot commented 1 year ago

πŸ“£ @s77rt You have been assigned to this job by @PauloGasparSv! Please apply to this job in Upwork 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 πŸ“–

PauloGasparSv commented 1 year ago

Hey everyone, sorry for the delay here!

I think it would be better to get broader confirmation on whether to do the refactor, there might be conscious reason why it was designed this way to begin with.

I'm also not comfortable with merging the P.R. without more reviews so I'll start a thread to discuss if we should implement the changes here and to get more reviewers in the P.R.

As we agree to do the refactor, both of these issues https://github.com/Expensify/App/issues/17637 & https://github.com/Expensify/App/issues/17710 won't happen anymore after the refactor.

Nice! I think it makes sense to put https://github.com/Expensify/App/issues/17710 on Hold for now since https://github.com/Expensify/App/issues/17637 is already on Hold @s77rt

Hmm, I am not sure about this. We don't clear the description text on the confirmation screen when going back to the amount page so I think we also shouldn't reset the selected value. Also I think it's pretty normal to use the back button when you wanna go back to edit something and it will not be a good experience to see that the changes you made are gone.

I was curious on how it would be implemented and if it would lead to the "Expected Result" so I was waiting to discuss about this in the P.R. I see @bernhardoj already agreed with the comment so I think we are not doing that anymore.

s77rt commented 1 year ago

@PauloGasparSv Please link to Slack thread about whether we should refactor the page or work on top of what we have.

PauloGasparSv commented 1 year ago

@PauloGasparSv Please link to Slack thread about whether we should refactor the page or work on top of what we have.

Sure thing @s77rt I'll start the thread once I finish this deploy blocker

conorpendergrast commented 1 year ago

@PauloGasparSv Were you able to start that thread?

cead22 commented 1 year ago

Hmm, I am not sure about this. We don't clear the description text on the confirmation screen when going back to the amount page so I think we also shouldn't reset the selected value. Also I think it's pretty normal to use the back button when you wanna go back to edit something and it will not be a good experience to see that the changes you made are gone.

I agree with this and not resetting the selections

bernhardoj commented 1 year ago

I see we have an announcement on expensify-open-source that we're doing a refactor to money request here https://expensify.slack.com/archives/C01GTK53T8Q/p1683642447007639. Should we hold this one then?

cc: @s77rt @PauloGasparSv

s77rt commented 1 year ago

I'm not really sure whether the refactor would cover this. @PauloGasparSv any idea?

conorpendergrast commented 1 year ago

@PauloGasparSv Bump on this confirmation please - can you confirm?

conorpendergrast commented 1 year ago

DM'ed Paulo now

PauloGasparSv commented 1 year ago

@bernhardoj @s77rt Sorry for the delay here!

I see we have an announcement on expensify-open-source that we're doing a refactor to money request here https://expensify.slack.com/archives/C01GTK53T8Q/p1683642447007639. Should we hold this one then?

IMO we should have holded for that. Since most changes related to that announcement are completed in newDot we can move forward with this.

I also don't think we should create a thread to discuss the refactor anymore. I realized that most of the logic for MoneyRequestModal is pretty recent and was done by @thienlnam (including the routing logic) so I asked them to review the P.R. too (adding them there once conflicts are fixed and it's ready for a re-review)

@bernhardoj can you please take a look at the P.R. conflicts? I'll start reviewing once that's done : )

bernhardoj commented 1 year ago

Got it. Will let you know when it's ready for review.

thienlnam commented 1 year ago

Did we ever start that slack thread for seeing if we should refactor this right now? This is a pretty big change and we're also implementing a lot of functionality on top of it right now.

I agree this would be a good change, but not sure if we should do this right now but pinging for thoughts

cc @vitHoracek @luacmartins

luacmartins commented 1 year ago

@thienlnam is this the proposal we are talking about? If so, it seems pretty self contained to MoneyRequestModal and I think most of the work there is done, so we should be good to work on it.

thienlnam commented 1 year ago

We're refactoring the MoneyRequestModal to move the "steps" to an individual screens - but if that's not a worry then we can move forward

luacmartins commented 1 year ago

Yea, I think that should be fine as I think we are not doing any more work in that area

conorpendergrast commented 1 year ago

Looking at the PR, the review is actively ongoing here

conorpendergrast commented 1 year ago

PR is still actively under review πŸ‘

conorpendergrast commented 1 year ago

PR is still under review, anything needed to keep that review going @PauloGasparSv @s77rt @bernhardoj ?

s77rt commented 1 year ago

Currently we are working on a bug and we have an ongoing slack discussion to work on that.

conorpendergrast commented 1 year ago

Looks like the PR is still under review! Any issues or trouble there?

bernhardoj commented 1 year ago

The discussion just completed and we are continuing the PR now πŸ‘.

conorpendergrast commented 1 year ago

Fantastic

PauloGasparSv commented 1 year ago

The P.R. is still in progress and has been consistently receiving updates and discussions.

@bernhardoj I don't think we have any blockers here but please LMK if we do