and it was going to be a disaster. Pixar leaders argued they needed to go back to what made Pixar, Pixar, so they scrapped the plot and engaged the original creative team from the first movie again to re-engineer the story. As part of that, the idea of Jessie's backstory with her owner was developed, and the song was brought in (but I don't know exactly when the song came into process). It brought the necessary emotional kick to make the story work, and basically saved Pixar and got them back on track for their future films.
At least, that's the story I remember reading somewhere.