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

Correct the logic for when bill split particpants can be selected #13279

Merged
merged 5 commits into from
Dec 6, 2022

Conversation

tgolen
Copy link
Contributor

@tgolen tgolen commented Dec 2, 2022

cc @luacmartins since it appears you flipped the logic in this PR: #11597 (comment). I was talking with @trjExpensify about it and that was a mistake.

Fixed Issues

$ #13220

Tests

Test the floating-action-button
  1. Click the floating action button
  2. Select Split Bill
  3. Enter an amount and click Next
  4. Select multiple people and click Next
  5. Verify that at the final confirmation screen, you CANNOT select or deselect anyone
Test the in-chat menu
  1. Go to a group chat
  2. Click the "+" button attached to the comment composer
  3. Select Split bill
  4. Enter an amount and click Next
  5. Verify that at the final confirmation screen, you CAN select and deselect people
  • Verify that no errors appear in the JS console

Offline tests

Same as the above tests, it should behave the same

QA Steps

Same tests as above

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
2022-12-02_11-22-50.mp4
Mobile Web - Chrome
2022-12-02_11-25-48.mp4
Mobile Web - Safari
2022-12-02_11-28-54.mp4
Desktop
2022-12-02_11-23-34.mp4
iOS
2022-12-02_11-26-50.mp4
Android
2022-12-02_11-24-48.mp4

@tgolen tgolen requested a review from a team as a code owner December 2, 2022 18:32
@tgolen tgolen self-assigned this Dec 2, 2022
@melvin-bot melvin-bot bot requested review from sketchydroide and sobitneupane and removed request for a team December 2, 2022 18:32
@melvin-bot
Copy link

melvin-bot bot commented Dec 2, 2022

@sobitneupane @sketchydroide One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@@ -57,7 +57,8 @@ const propTypes = {
phoneNumber: PropTypes.string,
})).isRequired,

/** Is this IOU associated with existing report */
/** Is this IOU associated with existing report. This is true when the action is initiated from inside a group chat and it's false when the action is initiated from the
* floating-action-button */
isIOUAttachedToExistingChatReport: PropTypes.bool.isRequired,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a part of me that wants to rename this prop to canModifyParticipants and make it more clear what's happening. Let me know if you agree.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah the name is hard to read and I don't understand what it supposed to be right now, your suggestion makes sense

Copy link
Contributor

@sketchydroide sketchydroide Dec 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's the only thing that it's doing right now, which it seems to be the case

@luacmartins
Copy link
Contributor

@tgolen I asked @JmillsExpensify about this change here and it seems like the DD mentions not being able to adjust members on this page. I'm happy to change if that's the intended behavior though

@JmillsExpensify
Copy link

Should we take this back to Slack?

@trjExpensify
Copy link
Contributor

It was changed later than the original release of N5 as a follow-up, so I imagine that's why it isn't in the OG doc when you looked there. It was changed to allow deselecting in a groupDM because sometimes not everyone in the group is part of every single shared expense, like if you created a group for a trip you were all going on a la splitwise. Else, you would have to create all these sub groups for when someone skips a dinner etc.

@@ -275,7 +276,13 @@ class IOUConfirmationList extends Component {
const shouldShowSettlementButton = this.props.iouType === CONST.IOU.IOU_TYPE.SEND;
const shouldDisableButton = selectedParticipants.length === 0;
const recipient = this.state.participants[0];
const canModifyParticipants = !this.props.isIOUAttachedToExistingChatReport && this.props.hasMultipleParticipants;

// The participants can only be modified when:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we do change the props name, maybe this somment makes more sense in the owner of this component?
Or at least part of it

sketchydroide
sketchydroide previously approved these changes Dec 5, 2022
Copy link
Contributor

@sketchydroide sketchydroide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is good as it is, but feel free to do the changes on the props name, will review again

Copy link
Contributor Author

@tgolen tgolen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, sounds like we are settled with this being the correct logic.

@sketchydroide I have renamed the prop and moved the location of the detailed comment as well. Thanks!

Copy link
Contributor

@sketchydroide sketchydroide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this makes more sense now

@sketchydroide
Copy link
Contributor

@sobitneupane happy to merge once you do your review

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sobitneupane
Copy link
Contributor

sobitneupane commented Dec 6, 2022

NAB: Noticed following things while testing the PR. Just noting down to make sure they are expected.

  • When we split bill from a group with three members (excluding user) and remove a member from IOU confirmation page, then new group with two members gets created with split message.
  • When we split bill from a group and remove all other members expect one from IOU confirmation page, then no split message appears any where. Only money requested message in one-to-one chat.
  • When we split bill from a room, new group (with members from the room) gets created with split message.

Copy link
Contributor

@sobitneupane sobitneupane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
Screen.Recording.2022-12-06.at.16.34.39.mov
Mobile Web - Chrome
Screen.Recording.2022-12-06.at.17.09.06.mov
Mobile Web - Safari
Screen.Recording.2022-12-06.at.17.11.36.mov
Desktop
Screen.Recording.2022-12-06.at.17.03.52.mov
iOS
Screen.Recording.2022-12-06.at.17.18.03.mov
Android
Screen.Recording.2022-12-06.at.17.13.52.mov

Copy link
Contributor

@sobitneupane sobitneupane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good and test well. Noted few things here just to make sure they are expected.

🎀👀🎀 C+ reviewed

cc: @sketchydroide @luacmartins

@trjExpensify
Copy link
Contributor

When we split bill from a group with three members (excluding user) and remove a member from IOU confirmation page, then new group with two members gets created with split message.

This isn't expected. The split message should go in the existing groupDM between all members. For example:

  1. As memberA, create a groupDM with memberB, memberC & memberD
  2. Go to the + menu inside the groupDM > click Split bill
  3. Enter $100 > click Next
  4. Deselect memberD > click Split $100
  5. The split action from memberA is added to the same groupDM: Split $100 with memberB and memberC
  6. In the memberA:memberB DM the request action from memberA is added: Requested $33.33 from memberB
  7. In the memberA:memberC DM the request action from memberA is added: Requested $33.33 from memberC
  8. In the memberA:memberD DM there is nothing added, as memberD was excluded from the split.

When we split bill from a room, new group (with members from the room) gets created with split message.

This isn't expected. Just to ensure we're on the same page though about why, is this what's happening?

  1. Create a groupDM with memberA, memberB, memberC, such that one exists between these three members
  2. Go to the + menu inside the groupDM and split a bill with all members
  3. A new groupDM gets created between userA, userB, userC such that there's now two groupDMs with exactly the same three members

DMs should always be unique. There can't be two DMs with the same members, whether that be a 1:1 DM or a groupDM.

When we split bill from a group and remove all other members expect one from IOU confirmation page, then no split message appears any where. Only money requested message in one-to-one chat.

This isn't expected either. If you're inside a groupDM and splitting a bill, the split message should be posted in that groupDM you took the action from, as that's your intention for visibility for the other group members, else you wouldn't be going through this flow? Writing it out for completeness:

  1. As memberA, create a groupDM with memberB and memberC
  2. Go to the + menu inside the groupDM > click Split bill
  3. Enter $100 > click Next
  4. Deselect memberC > click Split $100
  5. The split action from memberA is added to the same groupDM: Split $100 with memberB
  6. In the memberA:memberB DM the request action from memberA is added: Requested $50.00 from memberB
  7. In the memberA:memberC DM there is nothing added, as memberC was excluded from the split.

@sobitneupane
Copy link
Contributor

When we split bill from a room, new group (with members from the room) gets created with split message.

This isn't expected. Just to ensure we're on the same page though about why, is this what's happening?

  1. Create a groupDM with memberA, memberB, memberC, such that one exists between these three members
  2. Go to the + menu inside the groupDM and split a bill with all members
  3. A new groupDM gets created between userA, userB, userC such that there's now two groupDMs with exactly the same three members

@trjExpensify When we split bill from a room (not group), group gets created with split message.

  1. Create a room with memberA, memberB, memberC
  2. Go to the + menu inside the room and split a bill with all members
  3. A new groupDM gets created between userA, userB, userC

@trjExpensify
Copy link
Contributor

Oh, blanked on the room distinction on that one - my bad! I don't think that's expected either though. It's strange to take a split action inside a room, and then have it post to somewhere totally different.

@luacmartins
Copy link
Contributor

When we split bill from a group with three members (excluding user) and remove a member from IOU confirmation page, then new group with two members gets created with split message.

Interesting. I'm pretty sure this was the behavior before the refactors and I intentionally refactored the new command to do this. It seems like we need to change this based on @trjExpensify's comments?

When we split bill from a room, new group (with members from the room) gets created with split message.

@trjExpensify isn't this expected since these are IOUs (P2P) instead of an expense report? Do we wanna keep personal requests in policy rooms?

When we split bill from a group and remove all other members expect one from IOU confirmation page, then no split message appears any where. Only money requested message in one-to-one chat.

This seems like a bug. The current behavior adds both messages to a split request with just one other user.

@tgolen
Copy link
Contributor Author

tgolen commented Dec 6, 2022

I love all the comments about that, but would it be OK to move this outside of the PR? This PR is specifically about flipping the logic for when participants can be modified so all of this is out-of-scope.

@luacmartins
Copy link
Contributor

Ah yes, we can merge this and continue the discussion in Slack.

@luacmartins luacmartins merged commit 7d85f49 into main Dec 6, 2022
@luacmartins luacmartins deleted the tgolen-fix-iou-confirmation-user-selection branch December 6, 2022 18:05
@OSBotify
Copy link
Contributor

OSBotify commented Dec 6, 2022

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @chiragsalian in version: 1.2.38-6 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants