No idea what should happen, but if I was a developer and had multiple documents minimized, I would not randomly pick one document to bring to the forefront as I would have no idea which one the user wanted.
Even if you only have one document minimized, clicking the app icon only tells the app that you want it to be active. You may just want to create a new document.
Some apps may decide to activate the most recently hidden document. That is the guess that the developer chose to implement. I don't know why I would want the most recently hidden document to activate since I just hid it, but that may be what the developer decided to do.
The App should come to the forefront when you click on it. What you want to do with he app is then up to you. No guessing required.
So, when you pick a document to activate, it appears because you have told the app what you want to do beyond merely making the app frontmost.
If you disable minimizing documents to the App icon in Dock System Prefs, you will see each minimized document in the Dock and you can pick the desired document to activate.