### Summary

Triggering handlers with `ansible.builtin.meta: flush_handlers` in a role results in an error

### Issue Type

Bug Report

### Component Name

meta

### Ansible Version

```console
$ ansible --version
ansible [core 2.14.0b2]
  config file = /home/twouters/.ansible.cfg
  configured module search path = ['/home/twouters/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/twouters/ansible-2.14/lib/python3.10/site-packages/ansible
  ansible collection location = /home/twouters/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/twouters/ansible-2.14/bin/ansible
  python version = 3.10.7 (main, Sep  6 2022, 21:22:27) [GCC 12.2.0] (/home/twouters/ansible-2.14/bin/python)
  jinja version = 3.1.2
  libyaml = True
```


### Configuration

```console
# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
```


### OS / Environment

Arch Linux and Debian but probably irrelevant

### Steps to Reproduce

```
$ tree -Ap                   
[drwx------]  .
├── [drwxr-xr-x]  testrole
│   ├── [drwxr-xr-x]  handlers
│   │   └── [-rw-r--r--]  main.yml
│   └── [drwxr-xr-x]  tasks
│       └── [-rw-r--r--]  main.yml
└── [-rw-r--r--]  test.yml

3 directories, 3 files
```

```
$ cat test.yml 
- hosts: localhost
  pre_tasks:
    - ansible.builtin.command: /bin/true
      notify: do nothing
  handlers:
    - name: do nothing
      ansible.builtin.debug:
        msg: hello
  roles:
    - testrole
```

```
$ cat testrole/tasks/main.yml    
---

- ansible.builtin.command: /bin/true
  notify: noop

- ansible.builtin.meta: flush_handlers

- ansible.builtin.command: /bin/true
```

```
$ cat testrole/handlers/main.yml 
---

- name: noop
  ansible.builtin.debug:
    msg: world
```

### Expected Results

I expect the play to succeed and trigger the handler

```
$ ansible-playbook test.yml -l localhost
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost
does not match 'all'

PLAY [localhost] ***************************************************************************************

TASK [Gathering Facts] *********************************************************************************
ok: [localhost]

TASK [ansible.builtin.command] *************************************************************************
changed: [localhost]

RUNNING HANDLER [do nothing] ***************************************************************************
ok: [localhost] => {
    "msg": "hello"
}

TASK [testrole : ansible.builtin.command] **************************************************************
changed: [localhost]

TASK [testrole : ansible.builtin.meta] *****************************************************************

RUNNING HANDLER [testrole : noop] **********************************************************************
ok: [localhost] => {
    "msg": "world"
}

TASK [testrole : ansible.builtin.command] **************************************************************
changed: [localhost]

PLAY RECAP *********************************************************************************************
localhost                  : ok=6    changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
```

### Actual Results

```console
$ ansible-playbook test.yml -l localhost           [WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost
does not match 'all'

PLAY [localhost] ***************************************************************************************

TASK [Gathering Facts] *********************************************************************************
ok: [localhost]

TASK [ansible.builtin.command] *************************************************************************
changed: [localhost]

RUNNING HANDLER [do nothing] ***************************************************************************
ok: [localhost] => {
    "msg": "hello"
}

TASK [testrole : ansible.builtin.command] **************************************************************
changed: [localhost]

TASK [testrole : ansible.builtin.meta] *****************************************************************
ERROR! BUG: There seems to be a mismatch between tasks in PlayIterator and HostStates.
```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct
display.debug("extending task lists for all hosts with included blocks")
                    for host in hosts_left:
                        iterator.add_tasks(host, all_blocks[host])
                    iterator.all_tasks[iterator.cur_task:iterator.cur_task] = included_tasks
                    display.debug("done extending task lists")
                    display.debug("done processing included files")
                display.debug("results queue empty")
                display.debug("checking for any_errors_fatal")
                failed_hosts = []
                unreachable_hosts = []
                for res in results:
                    
                    
                    if (res.is_failed() or res._task.action in C._ACTION_META) and iterator.is_failed(res._host):
                        failed_hosts.append(res._host.name)
                    elif res.is_unreachable():
                        unreachable_hosts.append(res._host.name)
                
                if any_errors_fatal and (len(failed_hosts) > 0 or len(unreachable_hosts) > 0):
                    dont_fail_states = frozenset([IteratingStates.RESCUE, IteratingStates.ALWAYS])
                    for host in hosts_left:
                        (s, _) = iterator.get_next_task_for_host(host, peek=True)
                        
                        
                        s = iterator.get_active_state(s)
                        if s.run_state not in dont_fail_states or \
                           s.run_state == IteratingStates.RESCUE and s.fail_state & FailedStates.RESCUE != 0:
                            self._tqm._failed_hosts[host.name] = True