Firing alerts only during work hours

I’m trying to set up an alert that would only fire during work hours. I can’t use mute timings and silences because I use a dashboard which shows the list of alerts firing and I would like the alert to not be listed in this dashboard outside work hours. My plan is to set it up as the following :

query A : sum by (hostname) (my_metric{})

query B : reducer of query A

query Time : hour()

query C (condition) : Math operation : $B> 90 && $Time > 7 && $Time < 20

However, due to query A having multiple series for the label “hostname”, query C returns no data. I think this is because query Time does not have the same labels as query A. Is there a way to make query C work ?

The problem actually was from the terraform config I used to deploy the alert. Making this exact alert rule manually and then exporting it to terraform solved the problem.