First of all when trying to select “erase background” for instrument change text… the option is simply not there (we are of course in Engrave Mode under graphic editing) :
As far as I’m aware, hairpins don’t generally erase barlines, it would be any descriptive text shown alongside the hairpin that would need to erase their backgrounds.
You can change how long hairpins must be on the far side of barlines in order for them to cross the barline in Engraving Options > Dynamics.
This isn’t any fun if you have a lot of them to do, but you can add the hairpins as lines, add some Shift-X text that’s a few blank spaces, set the text to Erase Background, and move it into position. With the current drawing order, the text will erase the barline but not the lines you input.
Lily has already convince me to give up this approach, but let us not confuse “looks great” with “looks right”, from a purely aesthetic point of view, one may find one more attractive than the other !