You can make in-character decisions and actively pursue character advancement. The only time I see those two things being in conflict is if you’ve created a character who would not want to pursue whatever activities are the focus of the campaign, which is generally considered bad form anyway.
Because making decisions in-character is a process, not a result. If I give weight to OOC factors like potential XP gain in additional to the character's IC concerns, that's a different process than focusing exclusively on IC concerns.
For example, let's say the PCs are deciding between two competing priorities: answering an urgent call from their allies for military aid, or keeping their contractual commitments to the Wizards Guild to provide security at a new dig site. An exclusively IC decision-making process would only look at the character's motivations, loyalties, and priorities. That's a different mental process than considering all of those factors
in addition to trying to trying to give added weight to whichever choice will result in the fastest XP gain. Maybe my character has a love interest among the allies in need, but values their reputation for honestly highly, and thus doesn't want to break a contractual commitment. Weighing those competing priorities may be a hard choice, but it's a straightforward binary trade-off. Trying to add relative rates of XP gain as a factor in the decision instead turns it into a much more complicated multidimensional optimization problem.
Why does making decisions based on OOC factors have to be intrusive on immersion? If your goals and your character’s goals are in concert, being rewarded for pursuing them should only further enhance immersion.
Because my emotional state and the character's emotional state are different. It's hard enough trying to empathize with the character strongly enough to make decisions from their point of view, and based on their emotions rather than my own. I can do that while trying to keep an intuitive, OOC sense of the other players' moods so that I can make sure my IC decisions are also fun for the rest of the table. I can't do both of those while also trying to simultaneously make a rational extrapolation of which IC options will result in the fastest character advancement.
Also, my goals and my character's goals are almost never going to be in concert. My goal is to be a fun player (or DM) who contributes to everyone else having a great time while also enjoying myself. My character's goals are all framed in terms of the state of a made-up fantasy world. So unless it's an isekai game (and I've never actually played one of those) my goals and my character's goals are
literally worlds apart.