It is case by case, company by company, or state by state.
For CA, it is not illegal for a company not to pay bonus for those who leaves after the end of the PA plan year but before the payout date.
See Keith Taylor’s story from the link below. Also review the company’s bonus plan (if any) or talk with the HR staff for the eligibility of the bonus before submitting a 2-wk advance notice of your separation.
Try your best to pay back for your hard works for a year long, and good luck!!!
https://www.proformative.com/questions/should-annual-bonus-be-paid-employee-who-resigns-january