So apparently, when I handled the error the previous time, I normalized the menu entry from "Show marked books (7)" to be "Show marked books" and throw away the number in the parenthesis.
Turned out that when there is only one book marked, calibre changes the menu entry into "Show marked book" which would not match my test:
Code:
if safe_name.startswith("Show marked books")
So, I didn't take account of plural/singular forms

. If this indeed is the only the problem, the solution is just removing the "s" from my test.
You described the problem as a regression from the previous version, while this problem has been there all along. If you can confirm that it only happens when only one book is marked I will release a fix, otherwise, will have to dig deeper to find the cause.
Edit: That is why I was not able to re-produce the behavior, was testing with multiple books marked.