When to use removeEditorPanel()

I think this is due to how you’ve destructured it out. I believe dispatch works as a realtime “action”. So you need call dispatch() when you want to remove the panel.

Try this:

const { dispatch } = wp.data;
dispatch( 'core/edit-post' ).removeEditorPanel( 'discussion-panel' )