{"record":{"id":"c50dffa899e9b311","repo":"RocketChat/Rocket.Chat","slug":"room-not-on-that-team","errorCode":null,"errorMessage":"room-not-on-that-team","messagePattern":"room-not-on-that-team","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/services/team/service.ts","lineNumber":404,"sourceCode":"\n\t\tconst user = await Users.findOneById(uid);\n\t\tif (!user) {\n\t\t\tthrow new Error('invalid-user');\n\t\t}\n\t\tif (!canRemoveAnyRoom) {\n\t\t\tconst canSeeRoom = await Authorization.canAccessRoom(room, user);\n\t\t\tif (!canSeeRoom) {\n\t\t\t\tthrow new Error('invalid-room');\n\t\t\t}\n\t\t}\n\n\t\tconst team = await Team.findOneById<Pick<ITeam, '_id' | 'roomId'>>(teamId, { projection: { _id: 1, roomId: 1 } });\n\t\tif (!team) {\n\t\t\tthrow new Error('invalid-team');\n\t\t}\n\n\t\tif (room.teamId !== teamId) {\n\t\t\tthrow new Error('room-not-on-that-team');\n\t\t}\n\n\t\tdelete room.teamId;\n\t\tdelete room.teamDefault;\n\t\tawait Rooms.unsetTeamById(room._id);\n\t\tvoid notifyOnRoomChangedById(room._id, 'updated');\n\n\t\tif (room.t === 'c') {\n\t\t\tawait Message.saveSystemMessage('user-removed-room-from-team', team.roomId, room.name || '', user);\n\t\t}\n\n\t\treturn {\n\t\t\t...room,\n\t\t};\n\t}\n\n\tasync unsetTeamIdOfRooms(user: AtLeast<IUser, '_id' | 'username' | 'name'>, team: AtLeast<ITeam, '_id' | 'roomId'>): Promise<void> {\n\t\tif (!team) {","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/e4b8178b205510181a96ceefee043d0abcd13e5a/apps/meteor/server/services/team/service.ts#L386-L422","documentation":"Error \"room-not-on-that-team\" thrown in RocketChat/Rocket.Chat.","triggerScenarios":"Thrown at apps/meteor/server/services/team/service.ts:402 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the room actually belongs to the given teamId before attempting removal.","Use the correct teamId matching the room's teamId, or remove the room from the team it currently belongs to."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e4b8178b205510181a96ceefee043d0abcd13e5a","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}