QGIS using project variables in filter queries
Layer filters don't use QGIS expressions, and are instead handed directly off to the underlying data provider. So, for instance, a filter on a postgis layer is passed to postgres to evaluate, and accordingly must use postgres syntax and functions. This means QGIS expressions functions and features like variables don't work in layer filters.