diff --git a/include/class.ticket.php b/include/class.ticket.php
index 6854f6c64d863bbd262a240b49f43f21dc6ab9f6..ddfcd3f04e0379083dc1acd6a9431c423cd4d971 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -2840,7 +2840,11 @@ implements RestrictedAccess, Threadable {
                 $stats['overdue'] += $S['count'];
             if ($S['staff_id'] == $id)
                 $stats['assigned'] += $S['count'];
-            elseif ($S['team_id'] && $S['staff_id'] == 0)
+            elseif ($S['team_id']
+                    && $S['staff_id'] == 0
+                    && $teams
+                    && in_array($S['team_id'], $teams))
+                // Assigned to my team but uassigned to an agent
                 $stats['assigned'] += $S['count'];
         }
         return $stats;