Hiding menu item using COC
When you know where the error occurs, look at which variable is null. It seems to be packingSlipButton, therefore your code for getting a reference of the button doesn't seem to work.
I think that controlName() returns the button reference correctly, but you get null when you try to cast it to FormButtonControl, because it's not an instance of FormButtonControl class. The right type is FormFunctionButtonControl, I think. You can verify that by looking at what you get from controlName().