If you donate energy/resources at the same time as another captain, the system will only receive the donation from whoever was first and record it on the epic's messages page. Although it may have looked like your energy/resources were being deducted when you were donating, if your friend was faster by even 0.0001 of a second, only their donation will have been recorded.

If you were slower to donate, when you get back to the main galaxy page you will see the system has already returned to you the amount you'd tried to donate. Don't worry, you haven't lost anything!