The appearance of the Heaviside $\theta$ is due to imposing a condition of convergence on the circular arc section of the contour, $T_R$ as you call it. When $t \gt 0$, substitute $p = R e^{i \phi}$ and we have
$$\int_{T_R} dp \frac{e^{p t}}{p} = i R \int_{\pi/2}^{3 \pi/2} d\phi\, e^{i \phi} \frac{e^{R t \cos{\phi}} e^{i R t \sin{\phi}}}{i R e^{i \phi}}$$
Note that $\cos{\phi} \lt 0$ when $\phi\in (\pi/2, 3 \pi/2)$, so that the integral vanishes in the limit of $R \to \infty$ by Jordan's lemma only when $t \gt 0$. In this region, there is a pole at $p=0$ and by the residue theorem, $f(t) = 1$ here.
When $t \lt 0$, however, the integral about $T_R$ does not vanish, but blows up. Thus, we may not use this contour. Rather, we go the other way, using a new segment $S_R$ which goes to the right of $\Re{z} = \sigma$. Here, $\cos{\phi} \gt 0$ and so Jordan's lemma applies when $t \lt 0$ (and not when $t \gt 0$). In this region, there are no poles (this is why we always choose $\sigma$ to be to the right of all of the poles of $\hat{f}(p)$), so the integral over the closed contour is zero.
Therefore, the ILT of $\hat{f}(p) = 1/p$ is $f(t) = \theta(t)$.
Let $$I(u):=\int_0^{2\pi}\,\frac{\text{d}t}{\big(1+\cos(u)\,\cos(t)\big)^2}\,.$$
Note that $I\left(\frac{\pi}{2}\right)=2\pi=I\left(\frac{3\pi}{2}\right)$, which agrees with the formula $I(u)=\frac{2\pi}{\left|\sin^3(u)\right|}$ for $u\in\left\{\frac{\pi}{2},\frac{3\pi}{2}\right\}$. From now on, we assume that $u\in(0,2\pi)\setminus\left\{\frac{\pi}{2},\frac{3\pi}{2}\right\}$.
Let $z:=\cos(t)+\text{i}\,\sin(t)$; then,
$$I(u)=\oint_\gamma\,\frac{4\,z}{\text{i}\,\left(z^2+2\,\sec(u)\,z+1\right)^2}\,\text{d}z\,,$$
where $\gamma$ is the positively oriented unit circle $\big\{w\in\mathbb{C}\,\big|\,|w|=1\big\}$. That is,
$$I(u)=\frac{4}{\text{i}\,\cos^2(u)}\,\oint_\gamma\,\frac{z}{\big(z+\sec(u)-\tan(u)\big)^2\,\big(z+\sec(u)+\tan(u)\big)^2}\,\text{d}z\,.$$
Write $u_+:=-\sec(u)+\tan(u)$ and $u_-:=-\sec(u)-\tan(u)$. Define
$$f_u(z):=\frac{z}{\big(z^2+2\,\sec(u)\,z+1\big)^2}=\frac{z}{\big(z+\sec(u)-\tan(u)\big)^2\,\big(z+\sec(u)+\tan(u)\big)^2}\,.$$
You can write $$(z-u_+)^2\,f_u(z)=\frac{z}{\left(z-u_-\right)^2}$$
so that
$$\left.\frac{\text{d}}{\text{d}z}\right|_{z=u_+}\,\big((z-u_+)^2\,f_u(z)\big)=-\frac{u_++u_-}{(u_+-u_-)^3}=+\frac{\cos^2(u)}{4\,\sin^3(u)}\,.$$
Similarly, you can write $$(z-u_-)^2\,f_u(z)=\frac{z}{\left(z-u_+\right)^2}$$
so that
$$\left.\frac{\text{d}}{\text{d}z}\right|_{z=u_-}\,\big((z-u_-)^2\,f_u(z)\big)=-\frac{u_-+u_+}{(u_--u_+)^3}=-\frac{\cos^2(u)}{4\,\sin^3(u)}\,.$$
If $u\in\left(0,\frac{\pi}{2}\right)$, then $u_-<-1<u_+<0$. Hence, by the Residue Theorem,
$$I(u)=\frac{4}{\text{i}\,\cos^2(u)}\,\Biggl(2\pi\text{i}\,\text{Res}_{z=u_+}\big(f(z)\big)\Biggl)=\frac{8\pi}{\cos^2(u)}\,\left(+\frac{\cos^2(u)}{4\,\sin^3(u)}\right)=+\frac{2\pi}{\sin^3(u)}\,.$$
If $u\in\left(\frac{\pi}{2},\pi\right)$, then $0<u_+<+1<u_-$. Hence, by the Residue Theorem,
$$I(u)=\frac{4}{\text{i}\,\cos^2(u)}\,\Biggl(2\pi\text{i}\,\text{Res}_{z=u_+}\big(f(z)\big)\Biggl)=\frac{8\pi}{\cos^2(u)}\,\left(+\frac{\cos^2(u)}{4\,\sin^3(u)}\right)=+\frac{2\pi}{\sin^3(u)}\,.$$
If $u\in\left(\pi,\frac{3\pi}{2}\right)$, then $0<u_-<+1<u_+$. Hence, by the Residue Theorem,
$$I(u)=\frac{4}{\text{i}\,\cos^2(u)}\,\Biggl(2\pi\text{i}\,\text{Res}_{z=u_-}\big(f(z)\big)\Biggl)=\frac{8\pi}{\cos^2(u)}\,\left(-\frac{\cos^2(u)}{4\,\sin^3(u)}\right)=-\frac{2\pi}{\sin^3(u)}\,.$$
If $u\in\left(\frac{3\pi}{2},2\pi\right)$, then $u_+<-1<u_-<0$. Hence, by the Residue Theorem,
$$I(u)=\frac{4}{\text{i}\,\cos^2(u)}\,\Biggl(2\pi\text{i}\,\text{Res}_{z=u_+}\big(f(z)\big)\Biggl)=\frac{8\pi}{\cos^2(u)}\,\left(-\frac{\cos^2(u)}{4\,\sin^3(u)}\right)=-\frac{2\pi}{\sin^3(u)}\,.$$
In all cases,
$$I(u)=\frac{2\pi}{\left|\sin^3(u)\right|}=2\pi\,\left|\text{csc}^3(u)\right|\text{ for all }u\in\mathbb{R}\setminus \pi\mathbb{Z}\,.$$
In general,
$$\int_0^{2\pi}\,\frac{\text{d}t}{\big(1+r\,\sin(t)\big)^2}=\int_0^{2\pi}\,\frac{\text{d}t}{\big(1+r\,\cos(t)\big)^2}=\frac{2\pi}{\big(\sqrt{1-r^2}\big)^3}$$
for every $r\in\mathbb{C}\setminus\big((-\infty,-1]\cup[+1,+\infty)\big)$. Similarly,
$$\int_0^{2\pi}\,\frac{\text{d}t}{1+r\,\sin(t)}=\int_0^{2\pi}\,\frac{\text{d}t}{1+r\,\cos(t)}=\frac{2\pi}{\sqrt{1-r^2}}$$
for every $r\in\mathbb{C}\setminus\big((-\infty,-1]\cup[+1,+\infty)\big)$. Here, we pick the branch of $\sqrt{1-r^2}$ in such a way that $$\big|1-\sqrt{1-r^2}\big|<|r|$$ (i.e., the branch cuts are $(-\infty,-1]$ and $[+1,+\infty)$). That is, for $r\in\mathbb{C}\setminus\big((-\infty,-1]\cup[+1,+\infty)\big)$, the complex number $\sqrt{1-r^2}$ is in the open half-plane containing complex numbers with positive real parts; in short, $$\text{Re}\big(\sqrt{1-r^2}\big)>0\text{ for every }r\in\mathbb{C}\setminus\big((-\infty,-1]\cup[+1,+\infty)\big)\,.$$
Best Answer
When you go from the real integral to the complex integral you have made a mistake, for the final result (after accounting for the Jacobian) is more like $$e^{-i\pi/4}\int_{\mathbb T}\frac1{(\sqrt2+(1+i)z^{1/4})^2z^{3/4}}\,dz$$ so contour integration is not suitable for the integrand in that form (branch cuts get introduced with the fractional powers!). The original bounds are another minus, since the method requires a closed loop in the complex plane, usually corresponding to a whole-period $[0,2\pi]$ integral.