Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(tasks): hide internal tasks from activity (#76008)

Adam Bowker44c5a282026a
diff --git a/products/tasks/backend/facade/api.py b/products/tasks/backend/facade/api.py
index b173401f54f2..d54daa828a8a 100644
--- a/products/tasks/backend/facade/api.py
+++ b/products/tasks/backend/facade/api.py
@@ -5710,7 +5710,8 @@ def _task_activity_qs(team_id: int, user_id: int) -> QuerySet[TaskActivity]:
Rows outlive visibility changes (a task moving to a private channel, say), so the
visibility gate belongs on read rather than being enforced when projecting.
"""
- return TaskActivity.objects.filter(team_id=team_id, user_id=user_id, task__in=_visible_task_qs(team_id, user_id))
+ visible_tasks = _visible_task_qs(team_id, user_id).filter(internal=False, archived=False)
+ return TaskActivity.objects.filter(team_id=team_id, user_id=user_id, task__in=visible_tasks)
def count_unread_task_activity(team_id: int, user_id: int | None) -> int:
diff --git a/products/tasks/backend/tests/test_channels_api.py b/products/tasks/backend/tests/test_channels_api.py
index 28f5036f9c54..7cfd9bfd52b6 100644
--- a/products/tasks/backend/tests/test_channels_api.py
+++ b/products/tasks/backend/tests/test_channels_api.py
@@ -382,6 +382,21 @@ class TaskActivityAPITestCase(ChannelTaskAPITestCase):
# A teammate with no relationship to the task sees nothing.
self.assertEqual(self._rows(self.peer_client), [])
+ @parameterized.expand(
+ [
+ ("internal", {"internal": True}),
+ ("archived", {"archived": True}),
+ ]
+ )
+ def test_hidden_tasks_are_excluded_from_activity(self, _name, task_updates):
+ Task.objects.filter(id=self.task.id).update(**task_updates)
+ self._awaiting_input()
+
+ page = self.author_client.get(self._activity_url()).json()
+
+ self.assertEqual(page["results"], [])
+ self.assertEqual(page["unread_count"], 0)
+
def test_authored_message_shows_as_message_with_snippet(self):
self._post_message(self.peer_client, "looking into this")
row = self._row_for(self.peer_client, self.task)