I'd suggest disabling the button rather than hiding it. Users are normally happiest when the UI changes as little as possible, and keeping the button displayed but grayed out doesn't force a re-layout to occur.