### Apache Airflow version

2.7.1

### What happened

Unable to retrieve logs for task inside task group inside mapped task group.
Got `404 "TaskInstance not found"` in network requests

### What you think should happen instead

_No response_

### How to reproduce

```
from datetime import datetime
from airflow import DAG
from airflow.decorators import task, task_group
from airflow.operators.bash import BashOperator
from airflow.utils.task_group import TaskGroup

with DAG("mapped_task_group_bug", schedule=None, start_date=datetime(1970, 1, 1)):
    @task
    def foo():
        return ["a", "b", "c"]


    @task_group
    def bar(x):
        with TaskGroup("baz"):
            # If child task group exists, logs 404
            #  "TaskInstance not found"
            # http://localhost:8080/api/v1/dags/mapped_task_group_bug/dagRuns/manual__2023-09-21T22:31:56.863704+00:00/taskInstances/bar.baz.bop/logs/2?full_content=false
            # if it is removed, logs appear
            BashOperator(task_id="bop", bash_command="echo hi $x", env={"x": x})


    bar.partial().expand(x=foo())
```

### Operating System

debian 11 / `astro dev start`

### Versions of Apache Airflow Providers

_No response_

### Deployment

Astronomer

### 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)

"""Redirect from url param."""
        return redirect(url_for("Airflow.audit_log", **sanitize_args(request.args)))
    @expose("/dags/<string:dag_id>/audit_log")
    @auth.has_access_dag("GET", DagAccessEntity.AUDIT_LOG)
    @provide_session
    def audit_log(self, dag_id: str, session: Session = NEW_SESSION):
        dag = get_airflow_app().dag_bag.get_dag(dag_id, session=session)
        dag_model = DagModel.get_dagmodel(dag_id, session=session)
        if not dag:
            flash(f'DAG "{dag_id}" seems to be missing from DagBag.', "error")
            return redirect(url_for("Airflow.index"))
        included_events_raw = conf.get("webserver", "audit_view_included_events", fallback=None)
        excluded_events_raw = conf.get("webserver", "audit_view_excluded_events", fallback=None)
        query = select(Log).where(Log.dag_id == dag_id)
        if included_events_raw:
            included_events = {event.strip() for event in included_events_raw.split(",")}
            query = query.where(Log.event.in_(included_events))
        elif excluded_events_raw:
            excluded_events = {event.strip() for event in excluded_events_raw.split(",")}
            query = query.where(Log.event.notin_(excluded_events))
        current_page = request.args.get("page", default=0, type=int)
        arg_sorting_key = request.args.get("sorting_key", "dttm")
        arg_sorting_direction = request.args.get("sorting_direction", default="desc")
        logs_per_page = PAGE_SIZE
        audit_logs_count = get_query_count(query, session=session)
        num_of_pages = math.ceil(audit_logs_count / logs_per_page)