# Topic deletion should clear assignment

**URL:** https://meta.discourse.org/t/topic-deletion-should-clear-assignment/271996
**Category:** Bug
**Tags:** assign, fixed
**Created:** [July 18, 2023, 2:43pm UTC](https://meta.discourse.org/t/topic-deletion-should-clear-assignment/271996 "2023-07-18T14:43:33Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [July 18, 2023, 2:43pm UTC](https://meta.discourse.org/t/topic-deletion-should-clear-assignment/271996/1 "2023-07-18T14:43:33Z")

</div>

An internal user contacted me yesterday because he couldn’t find all the topics assigned to his group. The group count said (at the time) 2, but only one was listed.

Fast-forward to today, when I had time to look at it, and the count says 4 but only 3 are listed:

 ![Selection_1215](https://global.discourse-cdn.com/meta/original/4X/e/d/a/edacc8c1c351dafe1baf8462a0c4cf892bd0864e.png)

Fortunately \<cracks knuckles/\> we have [Data Explorer](https://meta.discourse.org/t/32566?silent=true) installed. It found all 4 for me:

 ![Selection_1216](https://global.discourse-cdn.com/meta/original/4X/2/2/0/2206f76ea8b33be166393f89388aa9cad5b4d2c0.png)

It turns out that somewhere between my assigning the topic and my colleague looking for it, the 4th was flagged by the user:

 ![Selection_1214](https://global.discourse-cdn.com/meta/original/4X/6/d/2/6d29dc4c4e4f9a1c27a814a3047ac1f12fa20c84.png)

and deleted by a 3rd colleague:

 ![Selection_1217](https://global.discourse-cdn.com/meta/original/4X/e/9/1/e91f1fc56800f0e5b3587a252c08790ca4294ea4.png)

IMO the assignment should have been removed as part of the deletion action.

---

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [July 18, 2023, 2:47pm UTC](https://meta.discourse.org/t/topic-deletion-should-clear-assignment/271996/2 "2023-07-18T14:47:19Z")

</div>

And in fact… I’m just noticing post creation / assignment / flag-and-remove dates are in April. And I don’t think the numbers were off (i.e. including deleted posts) until recently. I wonder if @nat’s [recent changes](https://meta.discourse.org/t/bad-group-assignment-count/252636/21) played a part in this.

---

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [August 24, 2023, 12:08pm UTC](https://meta.discourse.org/t/topic-deletion-should-clear-assignment/271996/5 "2023-08-24T12:08:48Z")

</div>

This happened again today, only worse:

 ![Selection_1296](https://global.discourse-cdn.com/meta/original/4X/4/4/0/44018e0deb4da7b3b7990f88bd039fc940c3c42b.png)

 ![Selection_1297](https://global.discourse-cdn.com/meta/original/4X/9/1/e/91ecc4f87b9481d90fc1374d3f75796b1c73076e.png)

Here’s my query:

```plaintext
SELECT a.* 
FROM assignments a
JOIN groups g on g.id=a.assigned_to_id
WHERE a.assigned_to_type='Group'
AND g.name='xxx'

```

In one of ‘deleted by author’ posts, my attempts to unassign it don’t “take”. I unassign, the action _does not_ show up in the thread, and a page refresh shows it’s still assigned to the group.

Edit: I had to undelete the topic before I could unassign it and get it removed from the group’s total assignment count. (Then re-deleted it.)

---

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [January 26, 2024, 5:30pm UTC](https://meta.discourse.org/t/topic-deletion-should-clear-assignment/271996/6 "2024-01-26T17:30:24Z")

</div>

This is still happening. I had one of my staff-users complain to me today:

 ![Selection_1523](https://global.discourse-cdn.com/meta/original/4X/3/b/2/3b21ab3543e5eb8c67e19ac13ec3d441abc34ffc.png)

I know y’all don’t prioritize until there’s been a certain amount of interest in a topic.

Can my encountering multiple instance and complaining for each one count as that? Please?

---

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [January 26, 2024, 5:32pm UTC](https://meta.discourse.org/t/topic-deletion-should-clear-assignment/271996/7 "2024-01-26T17:32:56Z")

</div>

Also, can someone add the `bug` label here, please?

---

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [March 26, 2024, 11:03am UTC](https://meta.discourse.org/t/topic-deletion-should-clear-assignment/271996/8 "2024-03-26T11:03:44Z")

</div>

Still happening…

 ![Selection_1663](https://global.discourse-cdn.com/meta/original/4X/e/1/6/e16f197cb840db3fa1c76e7fed2884ba76fce6c1.png)

---

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [March 13, 2025, 11:39am UTC](https://meta.discourse.org/t/topic-deletion-should-clear-assignment/271996/9 "2025-03-13T11:39:16Z")

</div>

This is still happening.

- User creates a thread
- We assign the thread to a group
- User deletes the thread
- The group can’t clear all its assignments because it can’t find the deleted, still assigned post

Surely we’re not the only ones seeing this?

---

<div class="post-metadata">

### Author: ![nat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nat/32/235063_2.png) [@nat](https://meta.discourse.org/u/nat)
#### Post date: [August 27, 2025, 10:19am UTC](https://meta.discourse.org/t/topic-deletion-should-clear-assignment/271996/11 "2025-08-27T10:19:03Z")

</div>

> [@ganncamp](#):
>
> - User creates a thread
> - We assign the thread to a group
> - User deletes the thread
> - The group can’t clear all its assignments because it can’t find the deleted, still assigned post

We just merged a [fix](https://github.com/discourse/discourse/pull/34564) and it is deployed to your site.

I’ll leave this topic open for two weeks in case of any further issues.

---

<div class="post-metadata">

### Author: ![ganncamp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ganncamp/32/106199_2.png) [@ganncamp](https://meta.discourse.org/u/ganncamp)
#### Post date: [August 27, 2025, 11:21am UTC](https://meta.discourse.org/t/topic-deletion-should-clear-assignment/271996/12 "2025-08-27T11:21:13Z")

</div>

Thanks @nat! This is great news 🎉

(Un)Fortunately, this is not an everyday thing, so my chances of encountering this either way within the next two weeks are slim.

---

<div class="post-metadata">

### Author: ![nat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nat/32/235063_2.png) [@nat](https://meta.discourse.org/u/nat)
#### Post date: [September 15, 2025, 12:00am UTC](https://meta.discourse.org/t/topic-deletion-should-clear-assignment/271996/13 "2025-09-15T00:00:33Z")

</div>

This topic was automatically closed after 18 days. New replies are no longer allowed.
