Question for gamesharing

So if I gift a game to the friend that is game sharing with me will I be able to play the game as well?

Short answer, yes. If the game was purchased twice (once by you for your console and once for the other console), then it will work no problem as long as two different accounts are playing the game. If you aren’t gifting games, then normal game sharing is explained in this link: https://www.ubergizmo.com/how-to/gameshare-xbox-one/.