It might be better to wash a hat in the dishwasher rather than the washing machine because it may lose its shape in the washing machine. However, check it is washable and contains no cardboard before placing it in your dishwasher.