From fbea7fd42c46c8c325e4741433b28c39f81ab4ef Mon Sep 17 00:00:00 2001 From: John Lee Date: Mon, 29 Apr 2024 11:54:23 -0400 Subject: [PATCH] Merge pull request #41222 from Expensify/revert-40272-fix/39495 Revert "Add error for failure invited member" (cherry picked from commit db37eb83417906f489f78411bc492d027472acf6) --- src/languages/en.ts | 3 --- src/languages/es.ts | 3 --- src/libs/actions/Report.ts | 34 +++++++++------------------------- src/pages/RoomMembersPage.tsx | 10 ---------- src/types/onyx/Report.ts | 1 - 5 files changed, 9 insertions(+), 42 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 610603e227e7..cab3a5ba342b 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2408,9 +2408,6 @@ export default { memberNotFound: 'Member not found. To invite a new member to the room, please use the Invite button above.', notAuthorized: `You do not have access to this page. Are you trying to join the room? Please reach out to a member of this room so they can add you as a member! Something else? Reach out to ${CONST.EMAIL.CONCIERGE}`, removeMembersPrompt: 'Are you sure you want to remove the selected members from the room?', - error: { - genericAdd: 'There was a problem adding this room member.', - }, }, newTaskPage: { assignTask: 'Assign task', diff --git a/src/languages/es.ts b/src/languages/es.ts index f9063fb560ac..8ad662ed3375 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2439,9 +2439,6 @@ export default { memberNotFound: 'Miembro no encontrado. Para invitar a un nuevo miembro a la sala de chat, por favor, utiliza el botón Invitar que está más arriba.', notAuthorized: `No tienes acceso a esta página. ¿Estás tratando de unirte a la sala de chat? Comunícate con el propietario de esta sala de chat para que pueda añadirte como miembro. ¿Necesitas algo más? Comunícate con ${CONST.EMAIL.CONCIERGE}`, removeMembersPrompt: '¿Estás seguro de que quieres eliminar a los miembros seleccionados de la sala de chat?', - error: { - genericAdd: 'Hubo un problema al añadir este miembro a la sala de chat.', - }, }, newTaskPage: { assignTask: 'Asignar tarea', diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 6fc51cd6b066..a0e31f553e7e 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2662,18 +2662,17 @@ function inviteToRoom(reportID: string, inviteeEmailsToAccountIDs: InvitedEmails onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, value: { - pendingChatMembers: - pendingChatMembers.map((pendingChatMember) => { - if (!inviteeAccountIDs.includes(Number(pendingChatMember.accountID))) { - return pendingChatMember; - } - return { - ...pendingChatMember, - errors: ErrorUtils.getMicroSecondOnyxError('roomMembersPage.error.genericAdd'), - }; - }) ?? null, + participantAccountIDs: report.participantAccountIDs, + visibleChatMemberAccountIDs: report.visibleChatMemberAccountIDs, + participants: inviteeAccountIDs.reduce((revertedParticipants: Record, accountID) => { + // eslint-disable-next-line no-param-reassign + revertedParticipants[accountID] = null; + return revertedParticipants; + }, {}), + pendingChatMembers: report?.pendingChatMembers ?? null, }, }, + ...newPersonalDetailsOnyxData.finallyData, ]; if (ReportUtils.isGroupChat(report)) { @@ -2696,20 +2695,6 @@ function inviteToRoom(reportID: string, inviteeEmailsToAccountIDs: InvitedEmails API.write(WRITE_COMMANDS.INVITE_TO_ROOM, parameters, {optimisticData, successData, failureData}); } -function clearAddRoomMemberError(reportID: string, invitedAccountID: string) { - const report = currentReportData?.[reportID]; - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, { - pendingChatMembers: report?.pendingChatMembers?.filter((pendingChatMember) => pendingChatMember.accountID !== invitedAccountID), - participantAccountIDs: report?.parentReportActionIDs?.filter((parentReportActionID) => parentReportActionID !== Number(invitedAccountID)), - participants: { - [invitedAccountID]: null, - }, - }); - Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, { - [invitedAccountID]: null, - }); -} - function updateGroupChatMemberRoles(reportID: string, accountIDList: number[], role: ValueOf) { const participants: Participants = {}; const memberRoles: Record = {}; @@ -3796,5 +3781,4 @@ export { leaveGroupChat, removeFromGroupChat, updateGroupChatMemberRoles, - clearAddRoomMemberError, }; diff --git a/src/pages/RoomMembersPage.tsx b/src/pages/RoomMembersPage.tsx index 67b6d96f182d..488bde658c3f 100644 --- a/src/pages/RoomMembersPage.tsx +++ b/src/pages/RoomMembersPage.tsx @@ -216,7 +216,6 @@ function RoomMembersPage({report, session, policies}: RoomMembersPageProps) { }, ], pendingAction: pendingChatMember?.pendingAction, - errors: pendingChatMember?.errors, }); }); @@ -225,13 +224,6 @@ function RoomMembersPage({report, session, policies}: RoomMembersPageProps) { return result; }; - const dismissError = useCallback( - (item: ListItem) => { - Report.clearAddRoomMemberError(report.reportID, String(item.accountID ?? '')); - }, - [report.reportID], - ); - const isPolicyEmployee = useMemo(() => { if (!report?.policyID || policies === null) { return false; @@ -240,7 +232,6 @@ function RoomMembersPage({report, session, policies}: RoomMembersPageProps) { }, [report?.policyID, policies]); const data = getMemberOptions(); const headerMessage = searchValue.trim() && !data.length ? translate('roomMembersPage.memberNotFound') : ''; - return ( diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index 6963d2eba8b9..3a30208da0a9 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -21,7 +21,6 @@ type Note = OnyxCommon.OnyxValueWithOfflineFeedback<{ type PendingChatMember = { accountID: string; pendingAction: OnyxCommon.PendingAction; - errors?: OnyxCommon.Errors; }; type Participant = {