Why does the Chat trigger fire when no agent is online in a department?
By default, triggers fire based on account status, rather than department status. You can add the condition Department status in your triggers to identify the status of the department instead of the account. The condition checks if at least an agent is online within the chosen department before the trigger is fired.
For more information about trigger conditions, see Zendesk Chat triggers conditions and actions reference.
For more information about status usage, see this article: Setting your chat availability status.