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-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
1 of 6 tasks
kbecciv opened this issue Apr 19, 2023 · 72 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@kbecciv
Copy link

kbecciv commented Apr 19, 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 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?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • 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

error-2023-04-18_19.55.50.mp4
Recording.2522.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
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Apr 19, 2023
@MelvinBot
Copy link

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

@MelvinBot
Copy link

MelvinBot commented Apr 19, 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

@conorpendergrast
Copy link
Contributor

Reproduced, thanks!

@conorpendergrast conorpendergrast added the External Added to denote the issue can be worked on by a contributor label Apr 20, 2023
@melvin-bot melvin-bot bot changed the title 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) [$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) Apr 20, 2023
@MelvinBot
Copy link

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

@MelvinBot
Copy link

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

@MelvinBot
Copy link

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

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

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

@dukenv0307
Copy link
Contributor

dukenv0307 commented Apr 20, 2023

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

const formattedParticipants = _.map(this.getParticipantsWithAmount(props.participants), participant => ({
...participant, selected: true,
}));

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

const formattedParticipants = _.map(this.getParticipantsWithAmount(props.participants), participant => ({
...participant, selected: true,
}));

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
Copy link
Contributor

huzaifa-99 commented Apr 20, 2023

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)
    }
}
  1. 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, 
}));
  1. 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
Screen.Recording.2023-04-20.at.3.00.42.PM.mov

What alternative solutions did you explore? (Optional)

N/A

@bernhardoj
Copy link
Contributor

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.

{currentStep === Steps.MoneyRequestConfirm && (
<AnimatedStep
style={[styles.flex1, safeAreaPaddingBottomStyle]}
direction={direction}
>
{modalHeader}
<MoneyRequestConfirmPage
onConfirm={(selectedParticipants) => {
// TODO: ADD HANDLING TO DISABLE BUTTON FUNCTIONALITY WHILE REQUEST IS IN FLIGHT
createTransaction(selectedParticipants);
ReportScrollManager.scrollToBottom();
}}
onSendMoney={(paymentMethodType) => {
// TODO: ADD HANDLING TO DISABLE BUTTON FUNCTIONALITY WHILE REQUEST IS IN FLIGHT
sendMoney(paymentMethodType);
ReportScrollManager.scrollToBottom();
}}
hasMultipleParticipants={props.hasMultipleParticipants}
participants={_.filter(selectedOptions, email => props.currentUserPersonalDetails.login !== email.login)}
iouAmount={amount}
iouType={props.iouType}
// The participants can only be modified when the action is initiated from directly within a group chat and not the floating-action-button.
// This is because when there is a group of people, say they are on a trip, and you have some shared expenses with some of the people,
// but not all of them (maybe someone skipped out on dinner). Then it's nice to be able to select/deselect people from the group chat bill
// split rather than forcing the user to create a new group, just for that expense. The reportID is empty, when the action was initiated from
// the floating-action-button (since it is something that exists outside the context of a report).
canModifyParticipants={!_.isEmpty(reportID)}
navigateToStep={navigateToStep}
/>
</AnimatedStep>
)}
</>
)}

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

const formattedParticipants = _.map(this.getParticipantsWithAmount(props.participants), participant => ({
...participant, selected: true,
}));
this.state = {
participants: formattedParticipants,
};

const formattedSelectedParticipants = this.getParticipantsWithAmount(selectedParticipants);
const formattedUnselectedParticipants = this.getParticipantsWithoutAmount(unselectedParticipants);

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.

this.setState((prevState) => {
const newParticipants = _.map(prevState.participants, (participant) => {
if (participant.login === option.login) {
return {...participant, selected: !participant.selected};
}
return participant;
});
return {participants: newParticipants};
});

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.

const [selectedOptions, setSelectedOptions] = useState(
ReportUtils.isPolicyExpenseChat(props.report)
? OptionsListUtils.getPolicyExpenseReportOptions(props.report)
: OptionsListUtils.getParticipantsOptions(props.report, props.personalDetails),
);

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 #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
Copy link

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
Copy link
Member

thesahindia commented Apr 21, 2023

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
Copy link
Member

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

🎀👀🎀 C+ reviewed

cc: @PauloGasparSv

@melvin-bot melvin-bot bot added the Overdue label Apr 24, 2023
@PauloGasparSv
Copy link
Contributor

I prefer @bernhardoj's #17662 (comment) 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 #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.

@melvin-bot melvin-bot bot removed the Overdue label Apr 24, 2023
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 24, 2023
@MelvinBot
Copy link

📣 @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
Copy link
Member

@PauloGasparSv, what's your opinion about #17662 (comment)

@bernhardoj
Copy link
Contributor

As we agree to do the refactor, both of these issues #17637 & #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
Copy link
Contributor

Ah, btw I agree with that #17662 (comment) as we also save description.

@bernhardoj
Copy link
Contributor

Accepted!

Btw, can we ask for a higher bounty as the PR is quite big and solves other issues too? 😄

@s77rt Do you agree?

@conorpendergrast
Copy link
Contributor

I will escalate that request to discuss in Slack!

@conorpendergrast
Copy link
Contributor

Discussing with C+ and Expensifiers in the C+ channel here

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Jun 23, 2023
@melvin-bot melvin-bot bot changed the title [$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) [HOLD for payment 2023-06-30] [$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) Jun 23, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jun 23, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 23, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot
Copy link

melvin-bot bot commented Jun 23, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.31-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-06-30. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Jun 23, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@s77rt] The PR that introduced the bug has been identified. Link to the PR:
  • [@s77rt] 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:
  • [@s77rt] 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:
  • [@s77rt] Determine if we should create a regression test for this bug.
  • [@s77rt] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@conorpendergrast] Link the GH issue for creating/updating the regression test once above steps have been agreed upon: https://github.com/Expensify/Expensify/issues/296776

@s77rt
Copy link
Contributor

s77rt commented Jun 24, 2023

  • The PR that introduced the bug has been identified: This seems to be an issue that existed since day one but back then there was no option to edit the Amount in the confirmation page but the issue was still reproducible on going back.
  • The offending PR has been commented on: n/a
  • A discussion in #expensify-bugs has been started: I don't think this is needed here. The regression test below should be enough to prevent this bug from resurfacing.
  • Determine if we should create a regression test for this bug: Yes

Regression Test Proposal

  1. Open any group chat
  2. Press the grey "+" button in the composer
  3. Press Split Bill
  4. Enter any amount then press Next
  5. Unselect any participant(s)
  6. Press Amount and change the amount
  7. Verify the unselected participants are still unselected

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Jun 30, 2023
@conorpendergrast conorpendergrast changed the title [HOLD for payment 2023-06-30] [$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) [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) Jul 3, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 3, 2023

Upwork job price has been updated to $2000

@conorpendergrast
Copy link
Contributor

From that discussion, we agree with raising the price to $2000. I've done that now, and it's also time to pay so that's nice

@melvin-bot melvin-bot bot removed the Overdue label Jul 3, 2023
@conorpendergrast
Copy link
Contributor

@conorpendergrast
Copy link
Contributor

All paid, contracts ended, all done. Closing out, thanks everyone

@bernhardoj
Copy link
Contributor

Thanks!

@melvin-bot
Copy link

melvin-bot bot commented Jul 31, 2023

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Aug 25, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 19, 2023

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

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. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
None yet
Development

No branches or pull requests