I'm pretty sure road and mountain are interchangeable on 8- and 9-speed drivetrains. Supporting info:
https://www.bikeradar.com/advice/buy...r-derailleurs/
There are a few exceptions (like Tiagra 4700 and old Dura-Ace), but I don't think those are in play in this situation. That said, that article concludes the Shimano section by saying:
And just for clarity, current generation Shimano road and mountain bike components are not inter-compatible with each other as they use different cable pull ratios. For example, you couldn’t use a set of road shifters with a mountain bike rear derailleur.