# Bug OP-5233 - Deleting a Group removes all Assignees from all Work package categories from all Projects

Project: OpenProject
Status: closed
URL: https://community.openproject.org/work_packages/OP-5233

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | High |
| Module |  |
| Target versions | 8.2.0 |
| Observed in versions | 8.0.0 |
| Sprint | 8.2.0 |
| Backlog bucket |  |
| Bug found in version (deprecated) | 8.0.x |
| Found in mobile app version |  |
| Follow-up feedback e-mail |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

**DESCRIPTION**  
When a group is deleted, all assignees from the work package categories are lost.  
Bug found in OpenProject 7.3.0, but present in 8.1.0 since OpenProject 5.x

  
**Preconditions**  
1\. At least one Project  
2\. At least one User who is Member of the Project with any Role  
3\. At least one Work package category in the Project with the User as Assignee

**Steps to replicate the problem**  
1\. Create a Group  
1.a. No need to add Users, but it does not matter  
1.b. No need to add the Group to a Project as a Member, but it does not matter  
2\. Delete the Group

**Expected behaviour**  
Only the Work package categories with the Group as Assignee shall be affected when deleting the Group

**Actual behaviour**  
ALL Assignees from ALL Work package categories from ALL Projects are deleted

**Source of the problem**  
File app/models/group/destroy.rb contains the code that deletes all Assignees from the Work package categories; it is an update of all records in the table categories in the database.  
Lines 90 to 96 update the Work package categories when the Group is deleted. It seems that between lines 95 and 96 a `.where` condition is missing, like in previous queries such as line 79:  
`       .where("#{members}.user_id" => self.id`
