The Flash S1 E22 has to happen between Arrow S3 E20 "The Fallen" and E21 "Al Sah-Him." In the Flash, after the team-up, Oliver mentions to Barry that "I may need a favor from you." In the Arrow finale, Oliver cashes in on that favor. We can tell this happens after the Flash episode because Barry tells the team
Well, I don't know what's been going on with him lately, apart from a recent wardrobe change, but one thing that hasn't changed is, he needs you guys. Even if he doesn't think so.
In the Flash episode, Barry had commented on the new outfit, so this scene in Arrow must have taken place after the teamup in Flash. Also, in the episode of the Flash, Barry tells Joe,
he has no idea where Nanda Parbat is, which wouldn't make sense if he has already been there to help Oliver in the Arrow finale.
Since "Al Sah-Him", events have been moving too quickly for Oliver to make any trips to Central City, but since Barry mentioned that Oliver was in Nanda Parbat, and Oliver showed up in League gear, it has to be after the end of "The Fallen". It's possible that in the early stages of his League training he was allowed some time off to help a friend, or that he could slip away from Ra's supervision for a couple hours to help Barry.
Another reason this probably happened earlier than the end of "Al Sah-Him" is because Oliver needed to know he could count on Barry in order to make his master plan for "My Name is Oliver Queen." As has been pointed out elsewhere, in the last couple days before the finale, Oliver had no contact with the outside world except through Malcolm Merlyn, whom Barry would probably not trust, given that he calls him a supervillain in the Arrow episode.
The other question still unanswered is where did the Palmer nanobots come from? I would have to guess that Ray developed them after his appearance on the Flash, and Oliver made some arrows with them before leaving to join the League, just in case, because Oliver is crazy prepared like that. If that's the case, he may not have even made them to fight Wells, they could have been a countermeasure to Barry if he went wild again. Ray couldn't have made them after "The Fallen" because neither he nor the rest of the team trusted Oliver after that, and as I said above this couldn't have happened after "My Name is Oliver Queen".