Repository: apache/airflow

Issue:
Dataset Next Trigger Modal Not Populating Latest Update
### Apache Airflow version

2.4.1

### What happened

When using dataset scheduling, it isn't obvious which datasets a downstream dataset consumer is awaiting in order for the DAG to be scheduled.

I would assume that this is supposed to be solved by the `Latest Update` column in the modal that opens when selecting `x of y datasets updated`, but it appears that the data isn't being populated.

<img width="601" alt="image" src="https://user-images.githubusercontent.com/5778047/194116186-d582cede-c778-47f7-8341-fc13a69a2358.png">

Although one of the datasets has been produced, there is no data in the `Latest Update` column of the modal.

In the above example, both datasets have been produced > 1 time.

<img width="581" alt="image" src="https://user-images.githubusercontent.com/5778047/194116368-ceff241f-a623-4893-beb7-637b821c4b53.png">

<img width="581" alt="image" src="https://user-images.githubusercontent.com/5778047/194116410-19045f5a-8400-47b0-afcb-9fbbffca26ee.png">


### What you think should happen instead

The `Latest Update` column should be populated with the latest update timestamp for each dataset required to schedule a downstream, dataset consuming DAG.

Ideally there would be some form of highlighting on the "missing" datasets for quick visual feedback when DAGs have a large number of datasets required for scheduling.

### How to reproduce

1. Create a DAG (or 2 individual DAGs) that produces 2 datasets
2. Produce both datasets
3. Then produce _only one_ dataset
4. Check the modal by clicking from the home screen on the `x of y datasets updated` button.

### Operating System

Debian GNU/Linux 11 (bullseye)

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



Discussion:
Just to expand upon the state that is causing this issue a bit more...

The DatasetEvent model looks correct in the database:
![image](https://user-images.githubusercontent.com/5778047/194351604-c013bf78-f296-4f5a-90b8-491ba0eb8e53.png)

Unsure why this query isn't populating the `lastUpdate` field in API response:
https://github.com/apache/airflow/blob/8898db999c88c98b71f4a5999462e6858aab10eb/airflow/www/views.py#L3447-L3451

![image](https://user-images.githubusercontent.com/5778047/194352487-de9fb002-62a1-4d35-8795-fa81dabfbe86.png)

@tseruga could you share the `created_at` time for the most recent dag run? I wonder if somehow dag run was created after the next update to `test_dataset`

https://github.com/apache/airflow/blob/8898db999c88c98b71f4a5999462e6858aab10eb/airflow/www/views.py#L3461-L3468

Feel free to assign this to me. I agree this should be more robust and clear in the UI

Resolving patch:
diff --git a/airflow/www/views.py b/airflow/www/views.py
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -3713,10 +3713,7 @@ def next_run_datasets(self, dag_id):
                 )
                 .join(
                     DatasetEvent,
-                    and_(
-                        DatasetEvent.dataset_id == DatasetModel.id,
-                        DatasetEvent.timestamp > DatasetDagRunQueue.created_at,
-                    ),
+                    DatasetEvent.dataset_id == DatasetModel.id,
                     isouter=True,
                 )
                 .filter(DagScheduleDatasetReference.dag_id == dag_id, ~DatasetModel.is_orphaned)


Test patch: