When we become convinced that God works all things together for good, we are grateful to a sovereign God. Thanksgiving indicates a heart that is at rest. We come to rest in the will of God and submit to whatever he chooses to do. Whatever the outcome we rest in God's sovereign hand. Thanksgiving means that we have peace about how God is going to answer.
Thanksgiving is one of the five categories of prayer.
The other four categories are confession, praise, petition and intercession. If we omit thanksgiving in prayer, our prayer is out of balance. They were not thankful at all. Their only focus was to get out of the jam. The heat was on and they were trying to squirm out.