Retirement tax questions

If you took out a loan from your 401k it doesn’t go on your tax return.  If you got a 1099R for it then it wasn’t a loan but a distribution.  Or you didn’t pay it back like if you stopped working there.  Why did you get the 1099R?  What code is in box 7?