### Apache Airflow version

2.4.1

### What happened

![image](https://user-images.githubusercontent.com/24224756/194797283-6c26ad63-d432-4c41-9f91-2dbc47417ec7.png)
when the sensor running, I can see the log above, but when I manual set the task state to failed or the task failed by other reason, I can't see log at here
![image](https://user-images.githubusercontent.com/24224756/194797633-0c7bf825-8e83-42af-8298-03491a26b7c9.png)
In other version airflow, like 2.3/2.2, this still happens

### What you think should happen instead

_No response_

### How to reproduce

_No response_

### Operating System

Ubuntu 20.04.4 LTS (Focal Fossa)

### Versions of Apache Airflow Providers

_No response_

### Deployment

Docker-Compose

### Deployment details

_No response_

### Anything else

_No response_

### Are you willing to submit PR?

- [ ] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)

"""Task Statistics"""
        allowed_dag_ids = get_airflow_app().appbuilder.sm.get_accessible_dag_ids(g.user)
        if not allowed_dag_ids:
            return flask.json.jsonify({})
        
        selected_dag_ids = {unquote(dag_id) for dag_id in request.form.getlist("dag_ids") if dag_id}
        if selected_dag_ids:
            filter_dag_ids = selected_dag_ids.intersection(allowed_dag_ids)
        else:
            filter_dag_ids = allowed_dag_ids
        running_dag_run_query_result = (
            session.query(DagRun.dag_id, DagRun.run_id)
            .join(DagModel, DagModel.dag_id == DagRun.dag_id)
            .filter(DagRun.state == State.RUNNING, DagModel.is_active)
        )
        running_dag_run_query_result = running_dag_run_query_result.filter(DagRun.dag_id.in_(filter_dag_ids))
        running_dag_run_query_result = running_dag_run_query_result.subquery("running_dag_run")
        
        running_task_instance_query_result = session.query(
            TaskInstance.dag_id.label("dag_id"),
            TaskInstance.state.label("state"),
            sqla.literal(True).label("is_dag_running"),
        ).join(
            running_dag_run_query_result,
            and_(
                running_dag_run_query_result.c.dag_id == TaskInstance.dag_id,
                running_dag_run_query_result.c.run_id == TaskInstance.run_id,
            ),
        )