The book Microelectronic circuits by sedra and smith,7e, OUP gives the equation for output resistance of a BJT cascode amplifier as:
\$R_{out} = r_{02} + (g_m r_{02})(r_{01} || r_{π2}) \$\$R_{out} = r_{02} + (g_{m2} r_{02})(r_{01} || r_{π2}) \$ as the term \$(1+ g_m r_{02}) \$\$(1+ g_{m2} r_{02}) \$ is nearly equal to \$(g_m r_{02})\$\$(g_{m2} r_{02})\$ assuming \$(g_m r_{02}) >>1 \$\$(g_{m2} r_{02}) >>1 \$.