I have no problem with the Soviets considering the ship a legitimate target at that point; the war in the east had no rules anyway. If I was the Soviet high command I would assume that either the passengers were military or they were civilians that may have been complicit in some of the atrocities from that period.
The collapse of the eastern front is interesting, as pockets of Germans were trapped further north (in Estonia/Latvia), while Finland as part of their separate peace with the USSR were expected to turn over German troops still in Finland.
Anything and everything was, well, if not necessarily "fair game", at least "game".
In any event, an enemy-flagged ship sailing in a declared war zone (which the Baltic certainly was) was presumably (almost certainly) carrying military personnel or material.
As, indeed, the Wilhelm Gustloff was doing.
The loss of civilian life was regrettable but one of those so-called collateral costs of war. In fact, the Soviet submarine commander probably didn't give it a moment's thought.