>>99776868If I'd have to guess I'd say they first came up with the idea of the family counseling and wanted to then create a subplot where Rick tries his hardest to not be apart of that.
Then you have to keep in mind that, according to Justin, the vast majority of the designs in the show first started with someone drawing a dick on a whiteboard and other people changing it up a bit, so they probably quickly came up with the idea of a pickle that way.
After that they created a story which would involve Rick from being a pickle to becoming a human again.
And at the end they gave it to Harmon to make it all even worse.
Probably not at all how it actually went but it's the best I got.