Query to filter out data based on two logic
So we're grouping by the combination of the sample_id and wheither timestamp IS NULL. The max is returned the group. MAX(NULL) is NULL so that case is covered.

SELECT sample_id, MAX(timestamp)
FROM table
GROUP BY sample_id, timestamp IS NULL