Why notice protects you
In almost all cases, yes. Giving the landlord written notice of the problem and a reasonable opportunity to fix it is usually a key requirement before you can move out and avoid owing rent over habitability issues.
The reason is fairness and proof: the landlord generally must know about a problem and have a chance to repair it before their failure can justify you leaving. Without notice, a landlord can argue they would have fixed the issue if only they had known, which can undermine your position and leave you responsible for rent.
Your notice should describe the problem clearly, be in writing, and be kept as a copy. If the landlord still fails to address a serious condition within a reasonable time, that documented failure supports your right to leave.
There can be nuances depending on the severity and the situation, but skipping notice is rarely wise. If you are thinking about moving out over conditions and are unsure what notice is required, a free, confidential review can help you understand the steps that protect your rights.
This is general information about California tenant rights, not legal advice. Every situation is different.