When we bought our house we had an inspection, too (worthless few hours of my life). The inspector missed that the panel, a new SquareD 100 amp box from Home Depot that was installed recently but did not have the city inspection sticker on it. That should have been a red flag, but it was missed.
After a lot of research and document collection I found out that this electrician wired the new panel up HOT, meaning the wires from the meter were completely hot when he wired them up into the new breaker. He avoided having the power company come out to disconnect the meter so he could wire up his panel. Why? Because to do that, he had to get a permit with the city. To get a permit with the city required an inspection. An inspection means everything had to be brought up to code.
Rewind to when this became a problem. We had no clue about the panel at this time. When we were remodeling our bathrooms we hired an electrician to run new home runs (we moved everything in the bathroom - long story but well worth it). Since we did get a permit for this major reno work, when the inspector came out to do the Rough electrical he looks at the panel and immediately says: "This is not an approved panel, the whole thing needs to be inspected. And I can already tell you have a major problem, the neutral wire is bare so the wire needs to be replaced". After further inspection the neutral wire was bare from the box to the meter, and the meter to the pole. It was bare even buried underground. This was a 1960s job so not to shocking. But anyway, we were told that to pass our inspection we had to bring this panel up to code. To say we my partner (now wife) at the time were pissed is an understatement.
We go back and review our documents because something did not sit right (8 months into new house). Turns out the seller marked "All improvements to the house were done with a permit". Big no-no lie. Lawyers involved on both sides. We got him to pay for the entire fix.
But it turns out it gets even better. So we hired this guy to run a new buried line, ~100 ft from pole to the existing meter location. We were going to replace everything with a new box, new digital smart meter, etc. Everything was going to stay in the existing location. They dig the trench 2' down, lay the cable, bury it to the house, and then start ripping out the old panel. We would be out of power for maybe a day.
It was a good thing I was home that day. So a little bit of description or orientation. The electrical panel was in the master bedroom in a corner of the house, the closest corner to the power pole, more or less. The panel basically sat, now in the inside, right up into the wall corner on one side, and on the other side was a 9' wide window. The electrical guys start ripping out the wall underneath the old panel since the new panel will be taller. After it is ripped out the worker inside starts doing something that shakes the entire window from the outside. I was standing outside and my 9'x4' window was shaking like it was the top of a drum after being hit. Seeing glass shake like that was terrifying. I run inside and yell for him to stop.
Once inside, I am standing there figuring out what he is doing. He is chipping away a wood stud so the new taller panel can fit. I kind of get nervous. Then I inspect this situation some more (with the wall opened up) and the old panel was installed the same way. About an 1" of the stud through the most of the 3.5" deep was chipped away. Turns out, most new electrical panels are 14.25" wide. I measured the cavity between the studs, 13.25". In order for the panel to fit in the 13.25" cavity, this stud had to be chipped. The other stud could not because it was in the corner. The panel couldn't move anymore into the corner. We had a big problem.
Well, after a bit of looking at this after everyone calmed down, it was further determined this stud was the king stud for the window framing. So not only did the previous electrician wire this all up hot without a permit, the electrician chipped away at a key window framing stud without any hesitation. What did this mean? It meant that the electrical wiring could not exist in that wall cavity. I looked for a 13" wide box, but I could not find one. What about outside? There was now not enough space between the corner and window side to be up to code. We had to move the meter and interior box. We had to move it to another corner. That meant the wire that was already laid down had to be dug up again, and then a new trench dug to the new location. An exterior panel was installed with the meter, and then a 200-amp line was run into the garage. This was the only place we could put the new panel without ripping up a deck, or moving the pole our service came from.
Long story - we didn't pay a dime for any of this. And it was expensive (double trenches). Lawyers were involved, with the smoking gun an actual receipt of the work done by the licensed electrician, no record of permit, and the seller's disclosure saying all improvements were permitted. It took months to sort this out.
Bottom line: do not have a box replaced without a permit. Just don't do it. And if you must insist, I guess you will have to mark "No" to whether all improvements were done with proper permits when selling.