Skip to content

Commit

Permalink
Merge pull request #39575 from s77rt/group-chat-isGroupChat-condition
Browse files Browse the repository at this point in the history
Use correct isGroupChat condition when creating a report
  • Loading branch information
marcaaron authored Apr 5, 2024
2 parents 2d380e5 + cb60efb commit ddb83f2
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import type {Route} from '@src/ROUTES';
import ROUTES from '@src/ROUTES';
import INPUT_IDS from '@src/types/form/NewRoomForm';
import type {
NewGroupChatDraft,
PersonalDetails,
PersonalDetailsList,
PolicyReportField,
RecentlyUsedReportFields,
ReportActionReactions,
ReportMetadata,
ReportUserIsTyping,
} from '@src/types/onyx';
import type {PersonalDetails, PersonalDetailsList, PolicyReportField, RecentlyUsedReportFields, ReportActionReactions, ReportMetadata, ReportUserIsTyping} from '@src/types/onyx';
import type {Decision, OriginalMessageIOU} from '@src/types/onyx/OriginalMessage';
import type {NotificationPreference, RoomVisibility, WriteCapability} from '@src/types/onyx/Report';
import type Report from '@src/types/onyx/Report';
Expand Down Expand Up @@ -212,12 +203,6 @@ Onyx.connect({
callback: (val) => (allRecentlyUsedReportFields = val),
});

let newGroupDraft: OnyxEntry<NewGroupChatDraft>;
Onyx.connect({
key: ONYXKEYS.NEW_GROUP_CHAT_DRAFT,
callback: (value) => (newGroupDraft = value),
});

function clearGroupChat() {
Onyx.set(ONYXKEYS.NEW_GROUP_CHAT_DRAFT, null);
}
Expand Down Expand Up @@ -799,14 +784,15 @@ function navigateToAndOpenReport(userLogins: string[], shouldDismissModal = true
let newChat: ReportUtils.OptimisticChatReport | EmptyObject = {};
let chat: OnyxEntry<Report> | EmptyObject = {};
const participantAccountIDs = PersonalDetailsUtils.getAccountIDsByLogins(userLogins);
const isGroupChat = participantAccountIDs.length > 1;

// If we are not creating a new Group Chat then we are creating a 1:1 DM and will look for an existing chat
if (!newGroupDraft) {
if (!isGroupChat) {
chat = ReportUtils.getChatByParticipants(participantAccountIDs);
}

if (isEmptyObject(chat)) {
if (newGroupDraft) {
if (isGroupChat) {
newChat = ReportUtils.buildOptimisticChatReport(
participantAccountIDs,
reportName,
Expand Down

0 comments on commit ddb83f2

Please sign in to comment.