App
App copied to clipboard
[$1000] 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)
If you havenβt already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
- Go to web chrome
- Go to group chat with 3+ members
- Click on plus icon and click on split bill
- Input a number
- Click on save
- Remove any member from the list
- Now click on amount and Save
- Notice that the member you removed earlier is again selected
- But now , again remove any member and click on description and Save
- 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?
- [ ] Android / native
- [ ] Android / Chrome
- [ ] iOS / native
- [ ] iOS / Safari
- [x] MacOS / Chrome / Safari
- [ ] MacOS / Desktop
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
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~014c6f23446b0fe33b
- Upwork Job ID: 1648965284444319744
- Last Price Increase: 2023-04-20
Triggered auto assignment to @conorpendergrast (Bug
), see https://stackoverflow.com/c/expensify/questions/14418 for more details.
Bug0 Triage Checklist (Main S/O)
- [x] This "bug" occurs on a supported platform (ensure
Platforms
in OP are β ) - [x] 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
- [x] 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.
- [x] 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.
- [x] I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
Reproduced, thanks!
Job added to Upwork: https://www.upwork.com/jobs/~014c6f23446b0fe33b
Current assignee @conorpendergrast is eligible for the External assigner, not assigning anyone new.
Triggered auto assignment to Contributor-plus team member for initial proposal review - @thesahindia (External
)
Triggered auto assignment to @PauloGasparSv (External
), see https://stackoverflow.com/c/expensify/questions/7972 for more details.
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)
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
- Add a new prop
onParticipantChange
toMoneyRequestConfirmationList
- Trigger the new prop
onParticipantChange
inMoneyRequestConfirmationList
whenever the state updates
componentDidUpdate(prevProps,prevState) {
if(!_.isEqual(this.state.participants, prevState.participants)) {
this.props.onParticipantsChange(this.state.participants)
}
}
- 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,
}));
- 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
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 π
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.
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.
I prefer @bernhardoj's proposal more because of the code refactor.
πππ C+ reviewed
cc: @PauloGasparSv
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.
π£ @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 π
@PauloGasparSv, what's your opinion about https://github.com/Expensify/App/issues/17662#issuecomment-1518071661
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!
Ah, btw I agree with that https://github.com/Expensify/App/issues/17662#issuecomment-1518071661 as we also save description.
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!
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?
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.
@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.
@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 π.
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.
I will take it!
Thanks @s77rt! @PauloGasparSv, please assign @s77rt here.
π£ @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 π
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.
@PauloGasparSv Please link to Slack thread about whether we should refactor the page or work on top of what we have.
@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