I don't see why TLS would impact anything in codec/media type selection if SRTP isn't involved.
First things first, check the media rules on the inside and outside of your SBC to make sure the incoming fax from the carrier's SDP passes from outside to inside with the same media parameters just to make sure the SBC isn't changing anything on the way in.
On site fax machines - presumably on analog ports on gateways belong to the network region of the gateway.
Let's just say...
Region 11 - Gateway
Region 1 - SIP trunks
Region 242 - IXM
Sig/trunk 1 - SIP trunks
Sig/trunk 242 - IXM
The far end network region of the SIP sig group defines the codec offer. So, let's say sig 1 and 242 have far-end network regions 1 and 242 respectively.
In ip-network-region 11, the codec set used to get to 1 could be codec-set 1.
In ip-network-region 1, the codec set used to get to destination 242 could be codec-set 5 like in your example.
The SBC has the A1 interface for incoming SIP calls which must exist in CM in the ip-network-map as pointing to ip-network-region 1.
When the inbound call flow happens, CM is going to use the IP address of the SBC interface to know it's from NR1 and your AAR thing makes it know it's going our sig group 242. Presumably you have codec set 5 for calls from NR1 to NR242.
Are the settings Initial IP-IP Direct Media and Direct IP-IP Audio Connections both set to yes in sig group 1 and sig group 242?
Is procr in NR1? Are gateways in NR1? If so, you have a design problem that makes it more complicated.
But, back to the inbound call flow for now. We know we're sending an invite out 242 with codec set 5. We know the IP representing A1 is in the map as NR1.
If the 2 settings are NO, then CMs invite will have a c= line for media to be be on a gateway and never change.
If direct IP = yes and Initial... = no, then CM will send the first invite with a c= line for media to be on a gateway and a reinvite with the c= line of A1 of the SBC to go direct.
If both are yes, then CM's initial invite will have the c= line be A1 of the SBC.
If there's a gateway in the first invite, then it depends whether that gateway's NR/codec supports t38 with 711fallback as a first choice. If so, it'll be in the original invite to IXM, if not, then it'll probably just be 711.
Then if you had direct ip YES and initial...NO, you'll try to shuffle based on what the IP of A1 (NR 1) can do and that where you see your reinvite. I would think fax stuff wouldn't like shuffling.
But, why do you care if you're using T38 or not on inbound? Only reason I can think of is speed. T38 is 9600baud and you can go up to 33.6 kbps on G711.
Couldn't you just work around the whole problem by turning off T38 on IXM and then T38 with 711 fallback is perfect everywhere? Outbound is T38 and inbound to IXM will always be 711?
If you know what the fax DIDs were, you could have fun in the BSC too by making that a URI group, and having another config for incoming calls only matching that URI group. It's topology hiding would, instead of changing the domain to customer.com change it to inc.fax.customer.com. You could have that domain in SM, point to CM, CM have a new sip SIG group with far-end domain inc.fax.customer.com and have no shuffling, hard coded settings, etc.