The simple answer is yes. If the office policy prohibits long or shaggy hair, then you need to adhere to that. If you keep long hair contrary to the company’s policy, then the employer will ask you to shave, or else you risk facing strict measures