I mean just imagine. You're Sanji, Chopper, Nami, or Brook. You just arrived on Zou thinking you're about to meet a bunch of people who you are very soon going to ally with. You step off the boat, and what you witness is a Country laid barren, with the inhabitants all on the verge of death. You and the team scramble to to run around and save as many people as you can, while fighting off an unknown enemy. Once things calm down a bit, you find out the harshly reality of what just happened. The subordinates of Yonko have just attacked Zou because Zou was hiding someone they thought was on the island. And entire Country almost wiped off the map in just 5 days.
Now you're Sanji and soon after you arrive, the subordinates of another Yonko crew show up, and demand you come with them to their Homeland. And they aren't giving you an option. They are telling you straight up how it is. Come with us, or everyone you knows dies. They are telling this to someone who just witnessed what a Yonko is capable of, and not to mention they are on the very same Island that another Yonko just destroyed, and if you don't leave with them right away, then another Yonko is going to send their full wrath to come collect you from that same Country.
This goes far beyond just "Wait and put your trust in Luffy." The threat is there, and is immediate. Action needs to be taken now, that is for the better benefit of everyone, not just the Straw Hats. The Minks have no fight left in them, and are all knocking on deaths door. The ultimatum is now. What was Sanji supposed to do? He had no clue when Luffy and the others were going to show up, but what he did know is that if he refused to go to WCI, he was bringing down the wrath of another Yonko on Zou. How people don't seem to understand this is beyond me.
Now to address the Sanji/Luffy situation on WCI. So you're Sanji, and you're thinking, maybe JUST maybe, Luffy would not be dumb enough to come all the way to WCI when the Straw Hats are about to go to war with another Yonko. An ignorant thought, but perhaps one of the other Straw Hats, or maybe even all of them will talk some sense into him, if he decides to to leave for WCI.
You're coming down the road, and who do you happen to spot? Luffy, who looks like he has just been put through the ringer, and his heavily beat up. You're with your family, who are already making comments on taking Luffy out, and you're balls deep inside of Big Mom's territory. What was he supposed to do? Welcome Luffy with open arms, give him a big old hug, and then team up with a heavily injured Luffy to take on the Vinsmokes? Ok, they'll probably win even with Luffy injured, but now, Luffy is even more injured, Sanji is injured, Nami is injured, and the rest of the Straw Hats are nowhere in sight. Guess what, they still can't leave the island. Now they have to find the rest of the Straw Hats. And bare in mind, Sanji doesn't know only a few of them came with Luffy, so in his mind, 6 crew members are missing.
So what's the best course of action here? Tell Luffy to leave, and he's not coming back? Like that'll work.... So Sanji made a snap decision. Attack Luffy and hope by some miracle, Luffy would take the hint, but even if he doesn't (Which Sanji knows he won't) it saves them from getting into a massive fight with the Vinsmokes, further injuring Luffy, and also injuring Nami. No matter what scenario you can try to come up with, Sanji did what he thought was best for the situation they were in.