You don't have to share Matthew with anyone on either route... it's optional! It's up to you to choose whether you want to do it alone, with Cody or with everyone else.
As for Josh, there are some scenes that you can't escape... it's part of the development of the story, but once it's over you don't have to share him with them if you don't want to.