How far are you and your friend into the game's storyline - does the game indicate about 93% of progression for any of you? If that's the case, then please note that starting from around 93%, all the quests (including side quests) need to be completed in single-player only by design. Once you complete the main campaign to 100%, co-op will become unlocked again.
If, however, your quest progression is below 93% and you still cannot join your friend(s):
Check your ports, please. See: Network ports used by Steam/PSN/XboxOne
CLEAR THE CACHE on all consoles that are trying to join each other.
Additionally, make sure no other account is logged into your Xbox besides your own account.
Also, if you have your Internet router set to IPV6, try changing it to IPV4.
What's more, if you have an external hard drive added to your console, uninstall the game, disconnect the drive and re-install the game to the console's default drive, please.
Lastly, if you cannot connect to a player in the same house with the same network, then please note that unfortunately, you cannot connect to a Dying Light co-op session twice from the same source. Only one console can connect from a network at a time.
A as a workaround, though, you could try searching the Net for articles on how to set up a DMZ for Xbox One, which might solve the issue at your end.