HAVE I MADE A TERRIBLE MISTAKE? I self-published an early draft of the manuscript I'm querying now (about 4 years ago), but I felt that since I changed the setting, plot, voice, and characters significantly it would count as a different book (thus, not self-published). What do I do???
Also should mention that I was a lousy marketer and eventually pulled it from the market (I feel that self-publishing was kind of a mistake, but, y'know, it was encouraging for a kid to see her work WITH AN ACTUAL COVER). If I had done some more marketing work maybe it would have gone better, but I'm pretty glad I didn't! But still. Do I have to do something?
By "do something" do you mean tell potential agents? Yes.
The real question is when.
I'd save it for the conversation you have when the offer is about to be made.
This isn't really a deal breaker, given the amount of time that's passed and that you didn't sell enough to get much traction.
You should also think about a title change; that's the thing that's most easily searchable on a book.
The reason you MUST tell the agent is contained in the warranties clause of the publishing contract she will hopefully obtain for you. That clause says, among other things, "the book has not been previously published."
Now, that is entirely negotiable but like most items in the contract you don't want to be doing it at the last minute. In fact your agent is going to be rightfully annoyed if you make her look like Bumblestiltskin and she has to go back to the editor and say "oh by the way."
I know how to finess things with a great deal of elan when given enough time to plot and connive.
This is not a terrible mistake.
It's a common mistake.