At the end, Shadow needs to end on the Black Comet, which is either by Final Haunt or the titular level, True Hero or Anti Villain respectively. In order for The Last Way to fit, it needs to be preceded by the most ambiguous ending. Final Haunt ends in either being a jerk to Sonic (oh, and Diablon is there too for some reason), or killing Black Doom to death. Anti Villain-Dark ends up with Shadow becoming the messenger of Black Doom, so all 3 of these are too clear cut. Anti villain-Hero on the other hand is the most ambiguous of all paths in the game, boiling down to telling Eggman "no one tells me what to do!" then bashing his skull in. Compare this to: destroying this DAMN planet, usurping Black Doom to conquer the Galaxy, usurping Eggman to take over the world, being better than himself (??), honoring Gerald's legacy aboard the collapsing ARK, or committing sudoku after finding the computer room.
Anyway, retconning the battle with Eggman and getting two chaos emeralds at the same time, this can easily lead into the last story. But how to get there? Working our way back, Shadow needs to think he's an Eggman Robot at some point from the final boss dialogue, which only happens in Iron Jungle, which connects to Black Comet thru the Dark Path.
Now from Westopolis, he either goes on to crash the Internet, go to an ancient Black Arms Ruin, or Escape from the City. These either lead to Eggman's Haunted Castle, what's left of Prison Island, or the DAMN fourth circus. For this game it would be most fitting for Shadow to go to Prison Island. In the third act, the Internet crashes no matter which path you take, so Digital Circuit feels rather irrelevant. In the beginning Shadow clearly doesn't care much for the humans at this point, so that leaves Glyphic Canyon.
This means Shadow betrays Doom twice in a row. The reasoning for this could be that Doom is remaining patient, as Shadow would be a fantastic asset to his cause. He is successively showing Shadow things that he hopes to turn him to the Dark side. At Prison Island, Shadow comes to the realization that Doom KNOWS a lot via flashback, and follows him for once in Prison Island.
After, Doom takes advantage of a mentally enervated Shadow and simulates the ARK raid in the Doom to give Shadow a reason to kill the humans. This backfires spectacularly however, as Shadow (after killing countless) finds Maria and for some reason helps her instinctively. To save this, Doom (inaccurately) represents Maria getting shot in front of Shadow for revenge. Since this conflicts with Shadow's only other established memory, he figures something is up and leaves after destroying the simulation machine.
He has a brief stint with Eggman, but doesn't believe him either and goes to the Black Comett, finding the other Emeralds and setting up the last story.