You can just change the selector as shown in How to avoid ghost numbering in headers? - #5 by Andrew.
#show heading.where(outlined: true): it => {
counter(heading).display(it.numbering)
}
This is a bit shorter too, though it’s 81 chars long, so it’s a bit too long to put on one line.