Sorry for reviving such an old post but I’ve run into this and the responses didn’t work for me. This code sample works for me.
TaskQuery taskQuery = _taskService.createTaskQuery();
taskQuery = taskQuery.or();
for (String subProcessId : processIds) {
taskQuery = taskQuery.processInstanceId(subProcessId);
}
taskQuery = taskQuery.endOr();
Hope that helps anyone else who is having this problem