A rental unit that is not a legal unit with the City is nevertheless subject to the Rent Ordinance unless exempt for another reason. To determine if a unit is legal, you will need to review the relevant public records at the Department of Building Inspection.
Tenants in illegal units who contact the Department of Building Inspection to report code violations should be aware that the inspector might cite the owner for having an illegal unit. In such cases, this means that the unit may have to be demolished or removed from residential use because it cannot be brought up to code requirements. Demolition or permanent removal of the unit from housing use is a “just cause” for eviction under the Rent Ordinance. However, the landlord must first obtain all necessary permits to remove the unit before an eviction notice can be given. The eviction notice must comply with the requirements of the Rent Ordinance as well as state law.
Source: San Francisco Rent Board