Modify _ensure_all_targets_allowed() to also work with path_hash_prefix