Gain on rental condo even though I sold less than what I paid for?

I bought a condo in 2005, converted it 12 years later to a rental property in 2017, and sold it in 2024. Is the "Business Portion" of the asset sale 100%, or is it the % of time it was a rental from 2017-2024? If it's the latter, it would be a rental for 7 of the 19 years of ownership which is 36.8% business portion.

 

More data:

11/2005 - condo purchased for 304k

 

1/2017 - condo rented out - I could have sold at that point in time for around 220k (loss due to housing crash in 2008); At that time I used that value of 220k for FMV.

 

8/2024 - tenant moved out; unit vacant until sale

 

12/2024 - condo sold for 265k

 

Condo was sold for a loss compared to what I initially paid. But it seems like turbotax is using the 220k estimate from 2017 when it converted to a rental to calculate a gain on my sale. I'm hoping I can accurately claim the 36.8% business portion as taking a loss on the sale of the property and then paying taxes on a "gain" is brutal. Should I go back to 2017 and change my FMV? I'm confused how I can pay on a gain that isn't really a gain; can anyone explain that to me? More info below:

 


My 4797 looks as follows:

 

Part I, line 2 - gross sales price (d) 90,618; cost or other basis (f) 71,181; gain (g) 19,437

line 6 gain - 54,628

line 7 combination gain - 74,065

 

Part 3, line 20 - gross sales price - 171,882

line 21 - cost or other basis plus expense of sale - 160,195

line 22 depreciation - 42,941

line 23 adjusted basis - 117,254

line 24 total gain - 54,628