App: [$250] [HOLD for payment 2024-04-09] [CRITICAL] [Groups] Frontend (Part 1): Create Group Chats + Splits. Deprecate Group DM creation. Support viewing both Group DMs and Group Chats.

Holding on:

Group Chats Design Doc

Changes described in detail here.

Goals

  • Update the the Group Chat creation flow UI to have a new “confirm” screen

Current UI:

Image

New UI (with differences noted):

Image

  • The creator will be shown as the “admin”

API call:

  • Set the chatType to group when calling OpenReport so the backend will know we are creating a “Group Chat” and add a constant for this.
  • For now, default avatar is fine - no need to have the upload yet.
  • Group name should also be non-interactive for now (we will add this later).
    • It should automatically take the standard name: %firstName%, %firstName%, …. one for each member, with the first member alphabetically appearing first (leftmost)
    • If a Group chat contains only one member because everyone else has left, then the default name will be %firstName%’s group chat
  • We should send a new param called groupChatAdminLogins. For now, it will include the creator of the chat only.

Migration notes:

  • We are moving from one kind of “Group DM” towards a new format of “Group Chat”
  • So, we must make sure that when merging this PR both Group DMs and Group Chats are still supported in all App versions. Though this new version should not create Group DMs and only create Group Chat. This means any existing Group DMs should be visible by all users. And old app versions can safely create Group DMs.
  • Splits should also be creating Group Chats instead of Group DMs (see this doc section)
  • Add the default Group chat avatar assets. Default to one based on reportID (as this won’t ever change) similar to how the default avatars are generated.

Image

This will all need to be performed in one App PR. We will hard deprecate older versions after it is deployed to production by updating the minimum app version so there is a hard dependency on this PR getting approved and merged:

Other things to note:

  • New Group Chats (like DMs) should have a notificationPreference of 'hidden' until a comment is left. We must ensure this behavior is preserved.

Implementation notes:

Our existing screen for this flow is: NewChatSelectorPage, but the Chat tab section is the NewChatPage. Its Modal stack navigator is here.

We need to: Modify the “Create group” button so that it says “Next”. Add an additional page to the NewChatSelectorPage stack navigator. Create a new page which we will call NewChatConfrmPage Add the appropriate routes for this page at /new/chat/confirm

Switching the button to “Next” here when we have tapped the “Add to group” option. Navigating to the new page

We need to add logic to navigate the user to the confirm page when they have selected “Add to group” here and have some staging participants.

We’ll also need some way for this new page to access those participants. The selectedOptions are currently stored here and house the members being added to the group. We will move them to a new Onyx key called newGroupChat that will be exclusively used to hold the state for a Group chat that is in the process of being created. This will allow the user to refresh the page and pick up where they left off (which is not possible today) and also allow us to share this state between all pages in the flow.

Start group button By this point, the newGroupChat Onyx state should have the following required data for the OpenReport API call: optimisticReportID optimistic accountIDs for any participants groupChatAdminLogins - should only contain the creator reportName - empty string (for now)

onPress we will navigate to the report just like we do already for Group DMs.

To do this, we will modify the navigateAndOpenReport() method here to handle the: memberRoles (if any) reportName

It already handles the logins. So, we need to add arguments for roles and reportName to that method. We must also modify the logic here when we have the group chat case since we won’t ever need to get an existing chat and will always be creating one.

The optimisticReport returned from ReportUtils.buildOptimisticChatReport() must be modified to update the participants field (see refactor plan here) with the corresponding role for each participant. Finally, the optimistic report is passed here to be created in the server. We must also pass the memberRoles as it will contain the link between any optimistic accountID and the login/email.

Group chat avatars will also need to display correctly in the Search function, Report header, details page, etc. We must modify the methods that get the avatars from personal details or workspace and first check for the report.avatarUrl. We can modify the existing ReportUtils.getIcons() method to first check the report.avatarUrl when we have a “Group chat” and fallback to a default avatar based off of the reportID.

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0174ced808f29e748c
  • Upwork Job ID: 1777806130629287936
  • Last Price Increase: 2024-04-09

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Comments: 58 (49 by maintainers)

Most upvoted comments

@waterim apologies, I must amend something that I’ve said WRT to the participant accountIDs as I did not notice until now 😅

(not shown, but we can also call it with an accountIDList as in this example - more on this below)

It’s true that we can call the API with an accountIDList - but I think we actually need to create a new request param like optimisticAccountIDList so we can check if any have changed. I’m working on this backend change now so it will be ready for us to test when we need it.

Hello, Im Artem from Callstack and already working on this!

All set. TY!

Noting that @marcaaron and I discussed this 1:1 and decided that there should be no regression penalties here. Marc flagged that @s77rt has gone above and beyond to do a great job working on this project, and any missed cases are not indicative of mistakes or anything like that.

So we’re going to pay out the full $500 to @s77rt for this one via Upwork.

Done! Thanks for your help on this one.

@marcaaron i think Wednesday is a most likely possible day for an open PR. i was busy on Friday, today got back to the task, resolving last your comment and would be able to proceed with creation!

@marcaaron Created a draft with ongoing changes, working on the create flow

After I merged main I found a weird bug related to new chat creation page, probably the issue with OptionsSelector itself. The issue is with selecting and deselecting people.

Here is a video with the bug from https://staging.new.expensify.com/new/chat

https://github.com/Expensify/App/assets/39777589/ffb6b74e-f32b-4a77-a1ca-88d52fcfb5c6

Do I need to report it or ticket already exists for this? @marcaaron @shawnborton

Let me see if I can get @dubielzyk-expensify to answer this one. I would guess we want these to be consistent with whatever we are doing now. They are SVGs so resizing should be no problem as they are vector graphics? Maybe I did not fully understand the question.

@waterim The .svgs are vector graphics so they scale nicely to 80x80. It’s only .pngs we need to export larger assets for. So yeah, you should be able to use the svg assets fine 😃

cc @Expensify/design

Maybe I should create a draft with ongoing changes to understand if Im on the right way

That sounds perfect. It will be easier to discuss some of these changes in the context of a PR and I can point you directly to the places in the code we need to update.

For now, I’ll answer your questions so far.

memberRoles and reportName, but where to pass those fields

When we are creating a Group Chat we will call the API with these parameters and some others.

2024-02-27_17-18-35

(not shown, but we can also call it with an accountIDList as in this example - more on this below)

Existing method where we call this API is here (use staging.expensify.com or expensify.com for testing).

The design has changed a bit. For the API we need to just take any “admins” and make sure they are in the list of groupChatAdminLogins.

API would then return something like this for the report object:

{
            "onyxMethod": "merge",
            "key": "report_3166052379363217",
            "value": {
                "reportID": "3166052379363217",
                "reportName": "Testing",
                "type": "chat",
                "chatType": "group",
                "ownerAccountID": 0,
                "managerID": 0,
                "policyID": "_FAKE_",
                "participants": {
                    "17356": {
                        "hidden": true,
                        "role": "admin"
                    },
                    "17357": {
                        "hidden": true,
                        "role": "member"
                    },
                    "17358": {
                        "hidden": true,
                        "role": "member"
                    }
                },
                "participantAccountIDs": [
                    17356,
                    17358,
                    17357
                ],
                "visibleChatMemberAccountIDs": [],
                "isPinned": false,
                "lastReadTime": null,
                "lastMentionedTime": null,
                "lastReadSequenceNumber": 0,
                "lastVisibleActionCreated": "2024-02-28 03:23:15.981",
                "lastVisibleActionLastModified": "2024-02-28 03:23:15.981",
                "lastMessageText": "",
                "lastActorAccountID": 0,
                "notificationPreference": "hidden",
                "stateNum": 0,
                "statusNum": 0,
                "oldPolicyName": "",
                "visibility": null,
                "isOwnPolicyExpenseChat": false,
                "lastMessageHtml": "",
                "iouReportID": null,
                "hasOutstandingChildRequest": false,
                "policyName": null,
                "hasParentAccess": null,
                "parentReportID": null,
                "parentReportActionID": null,
                "writeCapability": "all",
                "description": "",
                "isDeletedParentAction": null,
                "reportFields": null,
                "total": 0,
                "unheldTotal": 0,
                "currency": "USD",
                "submitterPayPalMeAddress": "",
                "chatReportID": null,
                "isWaitingOnBankAccount": false,
                "nonReimbursableTotal": 0,
                "isCancelledIOU": false
            }
        }

So we need our optimistic report here to have roughly the same participants object.

And regarding this part Finally, the optimistic report is passed here to be created in the server. We must also pass the groupChatAdminLogins. .

This was not worded correctly. But anyone who is an “admin” should get passed to groupChatAdminsLogins (for now it’s only the report creator - so not too much to worry about for this PR).

The trickiest part for this will be updating the participants accountID when we do not yet have them. We do something like this:

https://github.com/Expensify/App/blob/98461f987e08e1ee977bd60f4974513b84b3c93d/src/libs/actions/Report.ts#L736-L748

Which can also have a generated accountID for a user that may or may not exist yet:

https://github.com/Expensify/App/blob/98461f987e08e1ee977bd60f4974513b84b3c93d/src/libs/PersonalDetailsUtils.ts#L65-L76

So, this needs to be referenced in the participants object. Then the API should remove any of these “fake users”. Sounds complicated, but we can focus on users that exist for now and figure a few of the details out as we go if that works for you.

I think hopefully seeing the API request/response for this part will fill in some of the missing pieces. But please do not hesitate to let me know if anything else is unclear. Thanks very much! 🙇

My update: working on this, hopefully first half of the next week will finish with initial version for reviews