Why permits matter in a sale
When the county's records say two bedrooms and the house has four, appraisers and lenders notice. Unpermitted space usually isn't counted at full value, and some lenders won't finance a house with an illegal unit. A buyer with a loan may ask you to get permits first, which can mean opening walls, bringing things up to current code and waiting on the city.
Open violations and liens
If the city has issued a notice of violation, fines may come with it, and unpaid fines can be recorded as a lien on the property. Liens are paid from the sale price at escrow, so they don't block a sale, but they do come out of your proceeds. Pull together any notices you've received so the buyer can see what's open.
Telling the buyer
Disclose what you know about work done without permits. You don't need every detail, but if you or a past owner converted the garage, say so. A cash buyer who sees it on the walkthrough will factor it in either way, and putting it in writing protects you later. In San Francisco, the seller also provides a 3R report from the building department showing the permitted use of the house.
Accessory units and newer state rules
California has spent years making it easier to build and legalize accessory dwelling units, and some cities run programs for bringing older units up to code. A buyer may decide to legalize the unit after closing. That's their project, not yours. The Department of Housing and Community Development tracks the state rules, and your city's building department, like San Jose's Planning, Building and Code Enforcement, can pull the permit history on a specific address.