I would suggest to check the following:
stress1 = (F/A) + pressure + [i * (Mbending / Z )]
stress2 = (F/A) + pressure - [i * (Mbending / Z )]
with:
1/ F = axial force , > 0 , if tensile and negative if compressive.
2/ i = stress intensification factor , between 1 to about 5. (But there are tables in B31.1 or B31.3)
3/ Mbending = total bendig moment,
Allowable is : S from code if sigma1 and/or sigma 2 are > 0.
Otherways , there is buckling ( which is never checked by ANSI 31.3, it is the design responsability to check it , by adding extra guides,.. ), and one has to use the ASME VIII div 1 , procedure, i.e, calculate A and find out the allowable compressive stress B in psi.