# Kan ongelezen melding niet wissen na wijziging van machtigingen

**URL:** https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995
**Category:** Bug
**Tags:** personal-messages, fixed
**Created:** [13 juni 2024 om 21:17 UTC](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995 "2024-06-13T21:17:31Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![flarsric](https://avatars.discourse-cdn.com/v4/letter/f/51bf81/32.png) [@flarsric](https://meta.discourse.org/u/flarsric)
#### Post date: [13 juni 2024 om 21:17 UTC](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995/1 "2024-06-13T21:17:32Z")

</div>

**Priority/Severity** : low

**Platform** : Windows/Android

**Description** : On Windows and on Android, I’m seeing an unread personal message notification, but when I click on it, it says the page doesn’t exist or is private.

![image](https://global.discourse-cdn.com/meta/original/4X/a/f/8/af88ee8dc08eff5857e836943a108b1ebe61c2ef.png)  
There seems to be no way for me to clear the notification since I can’t read the message.

**Reproducible steps** : I haven’t tried to reproduce it, but what happened was I was removed as a recipient while the message was unread, so I no longer have permission to view the message.

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [13 juni 2024 om 21:22 UTC](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995/2 "2024-06-13T21:22:43Z")

</div>

> [@flarsric](#):
>
> There seems to be no way for me to clear the notification since I can’t read the message.

Does the number disappear when you reload the site?  
That’s what I did to get rid of the notification for a like when someone has liked one of my posts and deleted it immediately afterwards.

---

<div class="post-metadata">

### Author: ![flarsric](https://avatars.discourse-cdn.com/v4/letter/f/51bf81/32.png) [@flarsric](https://meta.discourse.org/u/flarsric)
#### Post date: [13 juni 2024 om 21:24 UTC](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995/3 "2024-06-13T21:24:08Z")

</div>

Nope, still there

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [13 juni 2024 om 21:37 UTC](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995/4 "2024-06-13T21:37:39Z")

</div>

I was able to reproduce the issue.

Clicking Dismiss removed the notification

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [14 juni 2024 om 03:51 UTC](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995/5 "2024-06-14T03:51:21Z")

</div>

If you can not dismiss it from the top, maybe try dismissing it from your profile, notification tab (there is a dismiss all) ?

I guess there are 2 questions here

1. How did the bug happen (my guess, maybe being kicked out of a PM can trigger this)?

2. How to get this annoying notification to go away (hopefully the dismiss stuff helps)

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [14 juni 2024 om 06:04 UTC](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995/6 "2024-06-14T06:04:22Z")

</div>

> [@sam](#):
>
> How did the bug happen (my guess, maybe being kicked out of a PM can trigger this)?

I followed the steps from the first post

> [@flarsric](#):
>
> **Reproducible steps** : I haven’t tried to reproduce it, but what happened was I was removed as a recipient while the message was unread, so I no longer have permission to view the message.

1. Send a message to a user
2. Remove the user from the message
3. Log in as this user
4. Get rid of the notification by dismissing all notifications

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [29 augustus 2025 om 16:29 UTC](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995/7 "2025-08-29T16:29:40Z")

</div>

Dit gebeurt nog steeds en het is nog steeds moeilijk om de melding kwijt te raken. Je kunt de enkele melding niet afwijzen, dus je moet eerst alle andere meldingen van berichten controleren.

Tot op zekere hoogte is dit zelfs een beveiligingslek, aangezien de gebruiker geen toegang meer mag hebben tot de titel van het bericht.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [31 augustus 2025 om 23:43 UTC](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995/8 "2025-08-31T23:43:45Z")

</div>

Ik heb een notitie voor het team geplaatst om de komende weken te triageren.

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [8 december 2025 om 17:23 UTC](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995/10 "2025-12-08T17:23:11Z")

</div>

Is there any news on this?

I still find it concerning that users I remove from a PM can still see title changes. This affects my ability to rename a topic that I convert into a personal message. There is a reason why I remove the user, and I don’t want them to have access to the new title.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [8 december 2025 om 19:13 UTC](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995/12 "2025-12-08T19:13:30Z")

</div>

I’ll see if i can reproduce 👍

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [9 december 2025 om 10:59 UTC](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995/13 "2025-12-09T10:59:14Z")

</div>

We were indeed missing some “cleanup” path when removing users from PMs (either directly or through a group).

[https://github.com/discourse/discourse/pull/36557](https://github.com/discourse/discourse/pull/36557)

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [9 december 2025 om 11:19 UTC](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995/14 "2025-12-09T11:19:39Z")

</div>

I think that’ll also fix [Sticky unread reply notification](https://meta.discourse.org/t/sticky-unread-reply-notification/384961).

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [12 januari 2026 om 20:41 UTC](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995/15 "2026-01-12T20:41:40Z")

</div>

This has been open for a while now. Is there anything else needed for this, or has there simply been no time to review and merge it so far?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [13 februari 2026 om 15:49 UTC](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995/16 "2026-02-13T15:49:11Z")

</div>

I have been working on fixing the root cause of several related inconsistencies regarding notification counts so my above PR has been superseded by this one

> <https://github.com/discourse/discourse/pull/36977>
>
> Notification badge counts could get "stuck" — showing a number higher
> than the a…ctual visible notifications. This happened because count
> queries used lightweight SQL (only filtering deleted topics), while
> display queries applied full access control via Guardian. When a user
> lost access to a topic — removed from a group/PM, or category
> permissions changed — the notification persisted in counts but was
> filtered from the displayed list.
> 
> Additionally, the \`visible\` scope had a logic error: the LEFT JOIN
> condition \`topics.id IS NULL OR topics.deleted\_at IS NULL\` incorrectly
> included notifications for hard-deleted topics.
> 
> The fix introduces \`NotificationQuery\` (following the \`BookmarkQuery\`
> pattern) — a centralized class that handles all notification filtering
> at the SQL level, ensuring counts always match displayed notifications.
> 
> Access control uses a CASE on topic archetype: PMs check
> topic\_allowed\_users + topic\_allowed\_groups; regular topics check
> category read\_restricted against the user's secure\_category\_ids. Shared
> drafts are excluded when the user lacks access. Admins without
> suppress\_secured\_categories\_from\_admin skip all checks. Badge
> notifications are handled via Ruby post-processing when enable\_badges
> is false.
> 
> To prevent DB bloat from orphaned notifications, model callbacks
> enqueue DeleteInaccessibleNotifications when access is revoked:
> 
> \- TopicAllowedUser after\_destroy — enqueues with topic\_id
> \- TopicAllowedGroup after\_destroy — enqueues with topic\_id
> \- GroupUser after\_destroy — enqueues with user\_id + group\_id
> \- Category after\_update — enqueues with category\_id when permissions change
> 
> The job supports three modes: topic\_id (checks each user via Guardian),
> category\_id (iterates topics, delegates to topic\_id mode), and
> user\_id + group\_id (finds affected topics, bulk-deletes where user
> lost access).
> 
> Redo of #27589.
> Ref - t/121464

---

<div class="post-metadata">

### Author: ![tannerabread](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tannerabread/32/526153_2.png) [@tannerabread](https://meta.discourse.org/u/tannerabread)
#### Post date: [12 augustus 2026 om 17:55 UTC](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995/23 "2026-08-12T17:55:58Z")

</div>

> [@Moin](#):
>
> This has been open for a while now. Is there anything else needed for this, or has there simply been no time to review and merge it so far?

This got delayed quite a bit by lots of changes in the affected area around the same time this was being worked on. Those PRs got too stale to revive — and I also noticed that it was my own doing that delayed these because I was the one making all of the changes in that area. So, I took this one on and have just merged a fix.

> <https://github.com/discourse/discourse/pull/42418>
>
> The notification list Guardian-filters inaccessible topics, but the unread-badge… counter (raw SQL COUNT) does not. When a user lost PM access, stale notification rows kept inflating the badge — the menu showed nothing new, but the count wouldn't clear.
> 
> Discourse already has \`Jobs::DeleteInaccessibleNotifications\` (used by \`TopicConverter\` and \`PostMover\`). This PR:
> 
> \- Wires it into \`Topic#remove\_allowed\_user\` (inline, Guardian-guarded so users with group-based access are preserved), \`Topic#remove\_allowed\_group\`, and \`GroupManager#remove/bulk\_remove\`.
> \- Narrows the \`GroupManager\` enqueue to topics where removed users actually have notifications, and passes \`user\_ids\` so the job scopes its work — prevents fan-out when a large group sits on many PMs.
> \- Rewrites the job: Guardian-check once per user (not per notification), single batched \`delete\_all\`, one publish\_notifications\_state\` per user.
> \- Adds a post-deploy backfill migration to clean up existing orphaned PM notifications.
> 
> Category-permission, trust-level, and direct \`GroupUser#destroy\` paths (SSO, auto-groups) are left as follow-ups.
> 
> \[\`/t/311995\`\](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995)
> \[\`/t/384961\`\](https://meta.discourse.org/t/sticky-unread-reply-notification/384961)

> [@Moin](#):
>
> I think that’ll also fix [Sticky unread reply notification](https://meta.discourse.org/t/sticky-unread-reply-notification/384961) .

I believe this is correct, and am also unsure it was still broken currently. Either way, it ~~should definitely~~ might be fixed after this merge.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [14 augustus 2026 om 18:00 UTC](https://meta.discourse.org/t/cant-clear-unread-notification-after-being-removed-from-a-pm/311995/24 "2026-08-14T18:00:16Z")

</div>


