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 5/30][$250] Allow creating a Group Chat with a single member #40258

Closed
marcaaron opened this issue Apr 15, 2024 · 41 comments
Closed
Assignees
Labels
Daily KSv2 External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item. Reviewing Has a PR in review

Comments

@marcaaron
Copy link
Contributor

marcaaron commented Apr 15, 2024

Coming from this thread we have decided that there is no real reason why a user should not be able to start a Group Chat with only themselves (h/t @shawnborton who noticed that we cannot do this).

Deliverable:

  • Investigate the front end code and determine what changes need to be made to allow a user to take the following actions:
  1. Add several people to a Group Chat via the Global Create menu
  2. Advance to the "Confim" page with the "Start group" button.
  3. Remove each member
  4. "Start group" button should allowing creating a group with only yourself.

Current behavior we need to improve:

Image

  • Verify if it appears that some backend changes need to be made (this is possible, I have not yet looked)
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~016c3003963dd24c78
  • Upwork Job ID: 1779998805262094336
  • Last Price Increase: 2024-04-15
  • Automatic offers:
    • abzokhattab | Contributor | 0
@marcaaron marcaaron added the NewFeature Something to build that is a new item. label Apr 15, 2024
@marcaaron marcaaron self-assigned this Apr 15, 2024
@marcaaron marcaaron added the External Added to denote the issue can be worked on by a contributor label Apr 15, 2024
Copy link

melvin-bot bot commented Apr 15, 2024

Triggered auto assignment to @Christinadobrzyn (NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details. Please add this Feature request to a GH project, as outlined in the SO.

@melvin-bot melvin-bot bot added the Weekly KSv2 label Apr 15, 2024
Copy link

melvin-bot bot commented Apr 15, 2024

⚠️ It looks like this issue is labelled as a New Feature but not tied to any GitHub Project. Keep in mind that all new features should be tied to GitHub Projects in order to properly track external CAP software time ⚠️

@melvin-bot melvin-bot bot changed the title Allow creating a Group Chat with a single member [$250] Allow creating a Group Chat with a single member Apr 15, 2024
Copy link

melvin-bot bot commented Apr 15, 2024

Job added to Upwork: https://www.upwork.com/jobs/~016c3003963dd24c78

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

melvin-bot bot commented Apr 15, 2024

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Apr 15, 2024
@abzokhattab
Copy link
Contributor

abzokhattab commented Apr 15, 2024

Proposal

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

Allow creating a Group Chat with a single member

What is the root cause of that problem?

new feature: enable creating a group chat with a single member

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

to achieve that we need to enable the confirm button to show up whenever we have one or members, we need to change this:

showConfirmButton={selectedOptions.length > 1}

to

showConfirmButton={selectedOptions.length > 0}

also, we need to change the onConfirm to:

onConfirm={selectedOptions.length > 1 ? createGroup : undefined}

onConfirm={selectedOptions.length > 0 ? createGroup : undefined}

finally we need to modify the isGroup condition inside the navigateToAndOpenReport to:

const isGroupChat = participantAccountIDs.length > 1;

    const isGroupChat = participantAccountIDs.includes(currentUserAccountID);

because when creating a group chat the current user id will be passed in the participants lists whereas in the direct dm we pass only the other party accountid

alternatively:

Given that the user cannot deselect themselves from the options, it is guaranteed that at least one option will always be selected. Consequently, we can eliminate the length check above.

showConfirmButton
onConfirm={createGroup}

@allgandalf
Copy link
Contributor

Proposal

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

Update code to Allow 1 person group feature

What is the root cause of that problem?

Feature request

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

First we need to allow the user to show the create group button and press confirm for even when participant length is 1, that can be done by changing the below to > 0 (we can even only check if the length exists):

showConfirmButton={selectedOptions.length > 1}

onConfirm={selectedOptions.length > 1 ? createGroup : undefined}

Then finally we need to update the navigateToAndOpenReport function to allow 1 person group, that can be done by updating the following condition to check isGroupChat for participants length greater than 0:

const isGroupChat = participantAccountIDs.length > 1;

This is enough to create the group of 1 person

What alternative solutions did you explore? (Optional)

@allgandalf
Copy link
Contributor

Verify if it appears that some backend changes need to be made (this is possible, I have not yet looked)

@marcaaron No backend changes would be required for this, my proposal covers all the places where we need to make the changes no additional changes required, also we need to update the `navigateToAndOpenReport,
result video using my proposal below:

Screen.Recording.2024-04-16.at.4.06.06.AM.mov

@allgandalf
Copy link
Contributor

allgandalf commented Apr 15, 2024

Hello @abzokhattab , can you please post in a comment stating that you updated some part of your proposal after my proposal, the contribution guideliens also state this too, thanks 😃

please go back and edit your original proposal, then post a new comment to the issue in this format to alert everyone that it has been updated:

c.c. @sobitneupane

@abzokhattab
Copy link
Contributor

abzokhattab commented Apr 15, 2024

Proposal Updated

Updated the isGroupChat condition to match the comment I proposed when we were considering the scenario of creating a group with a single member here: #39560 (comment)

Note: the third solution proposed here would also apply as another solution for this problem

@abzokhattab
Copy link
Contributor

@GandalfGwaihir thank you for your comment. Sorry, I forgot to add the proposal updated alert.

@nkdengineer
Copy link
Contributor

Proposal

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

Enable create group chat with only one user.

What is the root cause of that problem?

This is a new feature request.

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

  1. Since the current user option will always selected, we can remove the condition here and always show the confirm button
onConfirm={createGroup} 

onConfirm={selectedOptions.length > 1 ? createGroup : undefined}

showConfirmButton

showConfirmButton={selectedOptions.length > 1}

  1. We should add an extra param in navigateToAndOpenReport like isGroupChat with default value is false, use this instead of here or we can update the isGroupChat condition by checking it includes the current user or not because for selfDM we always navigate to this report.
    We should not use > 0 condition because it maybe a DM

And then pass isGroupChat as true here

Report.navigateToAndOpenReport(logins, true, newGroupDraft.reportName ?? '', newGroupDraft.avatarUri ?? '', fileRef.current, optimisticReportID.current, true);

Report.navigateToAndOpenReport(logins, true, newGroupDraft.reportName ?? '', newGroupDraft.avatarUri ?? '', fileRef.current, optimisticReportID.current);

Verify if it appears that some backend changes need to be made (this is possible, I have not yet looked)

I've tested and we don't need backend changes here.

  1. Since we allow create group chat with single use now, we should separate the Create Chat and Next button. So we can go to the confirm group page without select any option
const footerContent = useMemo(() => {
    /**
     * Creates a new group chat with all the selected options and the current user,
     * or navigates to the existing chat if one with those participants already exists.
     */
    const createGroup = () => {
        if (!personalData || !personalData.login || !personalData.accountID) {
            return;
        }
        const selectedParticipants: SelectedParticipant[] = selectedOptions.map((option: OptionData) => ({login: option.login ?? '', accountID: option.accountID ?? -1}));
        const logins = [...selectedParticipants, {login: personalData.login, accountID: personalData.accountID}];
        Report.setGroupDraft({participants: logins});
        Navigation.navigate(ROUTES.NEW_CHAT_CONFIRM);
    };

    return (
        <>
            <ReferralProgramCTA
                    referralContentType={CONST.REFERRAL_PROGRAM.CONTENT_TYPES.START_CHAT}
                    style={styles.mb5}
                />

                {selectedOptions.length === 1 && (
                    <Button
                        success
                        text={translate('newChatPage.createChat')}
                        onPress={createChat}
                        pressOnEnter
                        style={styles.mb5}
                    />
                )}
                <Button
                    success
                    text={translate('common.next')}
                    onPress={createGroup}
                    pressOnEnter
                />
        </>
    );
}, [createChat, personalData, selectedOptions, styles.mb5, translate]);

const footerContent = useMemo(() => {

What alternative solutions did you explore? (Optional)

NA

@ahmedGaber93
Copy link
Contributor

ahmedGaber93 commented Apr 16, 2024

Proposal

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

Allow creating a Group Chat with a single member.

What is the root cause of that problem?

new feature

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

For that we need 3 steps (important step 3).

  1. edit confirm button visibility here
// showConfirmButton={selectedOptions.length > 1}
showConfirmButton={selectedOptions.length > 0}
  1. edit confirm button onConfirm here
// onConfirm={selectedOptions.length > 1 ? createGroup : undefined}
onConfirm={selectedOptions.length > 0 ? createGroup : undefined}
  1. as we now allow creating a group chat with a single member, so we need to edit navigateToAndOpenReport here to differentiates between DM 1:1 and group chat with a single member, this function now is used in many places, so we need to confirm it will work fine in those cases (exist/not exist) for DM 1:1, group.

The only different now between DM 1:1 and group is participantAccountIDs.length > 1, and if we edit it to participantAccountIDs.length > 0 it will return true in both DM 1:1 and group with a single member, and if we pass isGroupChat as a parameter it will be hard code as we need to pass it in all cases (exist/not exist) for DM 1:1 and group.
So my fix for this is creating a new variable isSignalMemberGroupChat which differentiates between 1:1 DM and group with a single member, and the final isGroupChat definition will be isSignalMemberGroupChat or participantAccountIDs.length > 1

// remove old isGroupChat
//  const isGroupChat = participantAccountIDs.length > 1;

// we need to handle `isSignalMemberGroupChat` in (exist/not exist)
// for not exist group >>> participants === 1 and isDraftGroup called by cretae group(explained below).
// for exist group >>> participants === 1 and chatType is group.

// isDraftGroup definition
// as we pass `optimisticReportID` only when we create a new group, so if it not undeifined that mean this is draft group.
// we can also create new param isDraftGroup and pass it true when creating the group (only in this place)
const isDraftGroup = !!optimisticReportID;

const isSignalMemberGroupChat = participantAccountIDs.length === 1 &&
  (isDraftGroup || ReportUtils.getChatByParticipants(participantAccountIDs)?.chatType === CONST.REPORT.CHAT_TYPE.GROUP);

// the new `isGroupChat` will be
const isGroupChat = isSignalMemberGroupChat || participantAccountIDs.length > 1;

For backend, I don't think we need any changes.

Also, there is another issue when display group chat in search page, it displays with empty title, we need to open new issue if not exist or fix it by following this way in search page

What alternative solutions did you explore? (Optional)

@sobitneupane
Copy link
Contributor

sobitneupane commented Apr 16, 2024

Thanks for the proposal everyone.

Proposal from @nkdengineer and proposal from @ahmedGaber93 both solves the issue.

In @ahmedGaber93's proposal ReportUtils.getChatByParticipants(participantAccountIDs)?.chatType === CONST.REPORT.CHAT_TYPE.GROUP); will probably always return false as we skip group chat while looking for the report in getChatByParticipants function.

As navigateToAndOpenReport is used only in case of new group chat or general chats(existing and new), I believe we will be okay going with the @nkdengineer's proposal. I don't think we would want to go with the 3rd step though.

@marcaaron Should we include two buttons—one for group chat and one for normal chat—allowing users to create group chats either alone or with just one other user, as suggested in 3rd step of proposal?

@abzokhattab
Copy link
Contributor

abzokhattab commented Apr 16, 2024

Hi @sobitneupane @marcaaron

  1. what do you think about my proposal?
  2. i also proposed adding the isGroupChat as a function arg in this issue (third solution) as illustrated here can you please consider that.

@marcaaron
Copy link
Contributor Author

Should we include two buttons—one for group chat and one for normal chat—allowing users to create group chats either alone or with just one other user

No, we should make the change described in the issue. That would be a decision for the Design team to consider, not us.

@ShridharGoel
Copy link
Contributor

@sobitneupane @marcaaron Kindly consider my proposal for the same here: #39317 (comment)

@sobitneupane
Copy link
Contributor

Thanks for the proposal everyone.

Update Proposal from @abzokhattab looks good.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Apr 17, 2024

Current assignee @marcaaron is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@nkdengineer
Copy link
Contributor

No, we should make the change described in the issue. That would be a decision for the Design team to consider, not us.

@marcaaron I think we should discuss about this because if we want to create a group chat with only one user, we need to select another to allow go to next and then de-select this one. I have another ideal for this action that we can do the dropdown button that will have two option one is create a group chat one is create a single chat.

Screen.Recording.2024-04-17.at.17.11.38.mov

What do you think about it? And should we discuss with design team about this here?

@ShridharGoel
Copy link
Contributor

ShridharGoel commented Apr 17, 2024

@marcaaron @shawnborton What do you think about the below? This would show the option to start a chat with only the user themselves when no one else is selected. It will also handle the case when a selected user is unselected on the confirmation page.

Screen.Recording.2024-04-04.at.1.12.50.PM.mov

@melvin-bot melvin-bot bot added the Overdue label Apr 25, 2024
Copy link

melvin-bot bot commented Apr 26, 2024

@sobitneupane, @marcaaron, @Christinadobrzyn, @abzokhattab Whoops! This issue is 2 days overdue. Let's get this updated quick!

@sobitneupane
Copy link
Contributor

@abzokhattab Any update? When can we expect PR?

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Apr 27, 2024
@marcaaron
Copy link
Contributor Author

@abzokhattab Can we get please get an update on this one?

@melvin-bot melvin-bot bot removed the Overdue label Apr 29, 2024
@abzokhattab
Copy link
Contributor

Apologies for the delay.. was pretty busy the last few days.
working on it now.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 Weekly KSv2 labels Apr 30, 2024
@abzokhattab
Copy link
Contributor

the PR is ready here

@Christinadobrzyn
Copy link
Contributor

monitoring #41315

3 similar comments
@Christinadobrzyn
Copy link
Contributor

monitoring #41315

@Christinadobrzyn
Copy link
Contributor

monitoring #41315

@Christinadobrzyn
Copy link
Contributor

monitoring #41315

@Christinadobrzyn Christinadobrzyn added Daily KSv2 and removed Weekly KSv2 labels May 28, 2024
@Christinadobrzyn
Copy link
Contributor

Christinadobrzyn commented May 28, 2024

PR deployed to production 5 days ago so payment is coming up.

Payouts due:

Upwork job is here.

@sobitneupane are you paid in NewDot?

@sobitneupane or @abzokhattab I know this is a new feature but do we need a regression test for this?

@sobitneupane
Copy link
Contributor

@sobitneupane are you paid in NewDot?

@Christinadobrzyn Yup. I will request payment in NewDot.

@sobitneupane
Copy link
Contributor

sobitneupane commented May 28, 2024

Regression Test Proposal

  1. Add several people to a Group Chat via the Global Create menu
  2. Advance to the "Confirm" page with the "Start group" button.
  3. Remove all members
  4. Verify that the "Start group" button still shows up allowing you to create a group with only yourself.
  5. Click on "Start group" button and verify that the group is created.

DO we agree 👍 or 👎

@marcaaron
Copy link
Contributor Author

LGTM

@Christinadobrzyn Christinadobrzyn changed the title [$250] Allow creating a Group Chat with a single member [HOLD for Payment 5/30][$250] Allow creating a Group Chat with a single member May 29, 2024
@Christinadobrzyn
Copy link
Contributor

Regression test - https://github.com/Expensify/Expensify/issues/400167

Payment planned for tomorrow

@Christinadobrzyn
Copy link
Contributor

Ready for payment - no regression tests reported.

payment summary here - #40258 (comment)

Closing this out as complete but let me know if we need to reopen for anything!

@JmillsExpensify
Copy link

$250 approved for @sobitneupane

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Daily KSv2 External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item. Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests

10 participants