A male heir would have better grounds to contest than Joseph II did OTL but not by much. If he claims Bavaria by rite of his mother then he needs to get in line because Maria Josepha was the youngest daughter of Charles Albert and her older sister Maria Antonia had several sons, namely the Elector of Saxony and his younger brothers. Furthermore its questionable whether Bavaria can pass through a female line anyways in preference to the male Wittelsbachs of the Palatine branches. Traditional house law had always been that Bavarian or Palatine possessions would descend through all the branches of the Wittlesbach dynasty, though I think technically this is merely by convention not salic law.
And if Joseph or his son allows Bavaria to go to Charles Theodore and make a claim only on his death then they've confirmed the Palatine Succession and nullified their only claim to Bavaria, through Maria Josepha. It makes no sense to agree that Charles Theodore's claim as a member of the Pfalz-Sulzbach line can superceded Maria Josepha's but the Pfalz-Zweibrucken claim cannot. So a better tactic would be for the heir as Emperor to simply declare the Electorate vacant and distribute it to himself as an Imperial perogative. I think its a grey area, someone with more knowledge of the traditional laws of the HRE might be able to comment on the legality and regardless the other Wittelsbachs are bound to contest it (there are IIRC two surviving branches at the time, Zweibrucken and Gelnhausen), with Prussian support no doubt. He certainly would have no claim to the Palatinate. That would have to go to Zweibrucken. It would be a crazy over reach to try to take Bavaria, the Palatinate and Julich-Berg. The rest of Germany and probably even a friendly France would not stand for it.
Best case would be if Joseph had two sons. One becomes Emperor and the other is given Bavaria. Probably with some concessions in the Austrian Netherlands as Joseph attempted OTL. It wouldn't upset the balance of power as much but the Habsburgs would probably still have to fight for it.