It’s possible 2.3.16 simply doesn’t translate to 2.5.1–I vaguely remember having trouble importing older-version published files into 2.5.1. Other than that, might want to check your browser cache and clear it, see if that helps.
2.5.1, I feel, would be a genuine improvement over older versions, when it stops being a bit of a buggy mess.
It’s broken on 2.3.16 as well - I actually just recently bought the computer (Ubuntu 22 on a System76 Gazelle laptop), and have started using Twine on it: most of the Linux versions of Twine 2.5.1 didn’t open at all, and on the Linux 64 version of 2.5.1 and 2.3.16 this error was there from the start.
Cleared browser cache and the error has persisted. As another test I created a new story in 2.3.16 instead of importing one, and it has the same error.