Hiding Custom Buttons

Hi there!
Hope you’ll doing great

I created a custom button using JS script:

frm.add_custom_button('Mail Delivery', () => {
        frappe.new_doc('Mail Delivery', {
        })
      })

Output: :white_check_mark:

remove

I put that code inside a condition to show the button in just a certain case. Like this:

if(frm.doc.mailing_type == 'Internal')
    {
      frm.disable_save();
      frm.add_custom_button('Mail Delivery', () => {
        frappe.new_doc('Mail Delivery', {
        })
      })
    }

Otherwise, I don’t want to be displayed.

else
    {
      frm.enable_save();
      // frm.remove_custom_button('mail_delivery'); didn't work :neutral_face:
    };

How to do so?

Thanks in advance