it wasn't in the manga. but the episode was unexpectedly good.
very good story material but again, this made the episode good. but let's be clear, the writing is poorly made, the scenarists have no talent and don't deserve to work in this studio. now when they have material to make a long filler arc they compress the story in less episodes and throw here and then story jewels. the fact that hagoromo unlocked sharinga then rinnegan could have been explained in a mutch better way than just this random woman that he liked, he and his brother. even his relation with her was not well developped.
I suspect that kishimodo gave them headlines to the story but they didn't know write it into a good one.