So here was the issue if someone has this same problem.
It had nothing to do with WP smush. Any image altering action would have triggered this problem.
The issue arose from a recent site migration.
The wordpress files and database were moved to a different hosting provider.
In the new database somehow primary key and auto increment was not set in wp_posts and wp_postmeta. (ID and meta_id needs to be set to both primary key and auto increment).
This caused the problem (this time triggered accidentally by wp smush, or any other image operation, as they made new database entries with 0 as ID instead of a unique auto incremented primary key).
Fixed in phpmyadmin.
Solution found from comment by Pranoy Sinha on this website https://sebastian.expert/fix-wordpress-an-error-occurred-in-the-upload-please-try-again-later/. Thanks Pranoy.
Hope this can be useful for someone else.
For search visibility:
wordpress media library images no images shown after image upload