There are plenty of things that are not illegal that would also not be acceptable in many workplaces. For example: drinking on the job, coming to work without a shirt on, giving everyone a nickname (e.g. "beardy") and exclusively referring to them by such, etc. You don't have a right to a job, so companies can fire you for any of these reasons. It would be weird if committing a misdemeanour or felony on the job meant you would get to keep working until your trial is over, but you could be fired on the spot for having a beer.