fixes #4906 Doble AND in workflow query

Fixed the issue and committed code for review, please check it.