There should be a more suitable solution for deleting projects than the existing one.
I suggest implementing a way to archive projects so they will become unavailable for further actions but won’t be deleted.
Since tasks don’t (always) belong to a project, I would idd advice using an archive status for projects.
That way, the tasks can stay untouched, they’re linked to an old archived project (which is still accessible if needed)
And modify the project page, to have a ‘active’ (default selected) and ‘archived’ button.
Similar to the invoice page, where you have draft/paid/etc