Sounds fine, actually, other than the potential AoO for moving out of the threatened square to get around the opponent.
There are several situations possible though, depending on initiative and which round of combat it was:
In first round of combat, if the attacker had gone before the rogue, but the comrade had not, then the Rogue could not sneak attack or receive a flanking bonus. The opponent would not be flat-footed (because he's acted) and the comrade would not threaten the opponent (because the comrade is flat-footed), so the opponent is not technically flanked yet. Also, attempting to move behind the opponent from the position described would provoke an AoO.
In the first round of combat, as long as the opponent has not gone, he is flat-footed and can be sneak attacked, even if the rogue does not move before attacking. If he moves, he will not provoke an AoO (because the opponent is flat-footed and does not threaten any squares), but he would not receive a flanking bonus unless his comrade had already gone (thus not being flat-footed anymore).
In subsequent rounds of combat, no one is considering flat-footed any longer, so as long as the rogue can flank the opponent, he can sneak attack and receive the flanking bonus. He may have to deal with an AoO to get there, however.