You need to map the IMAP folders to Mail's main mailboxes. In the sidebar, you should have a GMail folder for the imap mailboxes. Put the cursor over it and choose expand. Highlight the Sent Messages folder and choose from under View in the menu " Use This Mailbox For" and choose Sent mailbox. You can do the same for Trash. This will move the gmail's imap Sent Messages folder to Mail's Sent folder. It will push the local sent folder out to the On My Mac local mailboxes. You can move the messages from there back to the main Sent mailbox and delete the local mailbox.
Once the mailbox is mapped to the main, you will note in preferences under mailbox behaviors (in Accounts tab) that sent messages should be checked to store on the server.
I have put many posts out on configuring gmail's settings for several things including gmails odd behavior of deleting messages. You should search for those post and read them.
Note: The above is assuming that you have gmail configured as an IMAP account.
If you have set up everything as suggested, then it should work. I never used the All Mail folder or Delete Messages folder and didn't show those in IMAP.
Assuming you have set up everything correctly and storing sent messages on the server, all sent messages should show up. One setting you might check is at the gmail site. Make sure you have it set to save a copy of sent messages checked there.
The All Mail folder shows messages in all gmails folders. You might look at a sent messages there and see which mailbox it is saved in. Make sure it's saving it in the main gmail Sent messages folder and not a seperate one created. Look at the Labels tab in settings and make sure it is set to show the main Sent Messages in imap and there are no others created at the bottom section.