Here is a good site which explains the use of future perfect with time clauses.
We use the Future Perfect Continuous to show that something will
continue up until a particular event or time in the future. "For five
minutes," "for two weeks," and "since Friday" are all durations which
can be used with the Future Perfect Continuous. Notice that this is
related to the Present Perfect Continuous and the Past Perfect
Continuous; however, with Future Perfect Continuous, the duration
stops at or before a reference point in the future.
They will have been talking for over an hour by the
time Thomas arrives.
She is going to have been working at that
company for three years when it finally closes.
James will have
been teaching at the university for more than a year by the time he
leaves for Asia.
How long will you have been studying when you graduate?
We are going to have been driving for over three
days straight when we get to Anchorage.
A: When you finish your
English course, will you have been living in New Zealand for
over a year?
B: No, I will not have been living here that long.
Notice in the examples above that the reference points (marked in
italics) are in Simple Present rather than Simple Future. This is
because these future events are in time clauses, and you cannot use
future tenses in time clauses.
Looking at your first sentence above, you wrote:
We do it when she has returned.
Instead, you should have written:
We will have been doing it when she returns.
Your second sentence -
I do not know if she will have been returned next week.
is not idiomatic. You should instead say one of the following, to express that you do not know whether or not she will be back by then:
I do not know if she will be returning next week
I do not know if
she will have returned by next week
I do not know if she will return
As you are particularly interested in expressing the idea of already back by then then the best choice of the three above is:
I do not know if she will have returned by next week
That most closely emphasizes the idea of already back by then while the other two emphasize back by then, not already back.
Your third sentence -
I am not sure if they will have been there by the time you arrive.
could actually be interpreted as they had arrived before you and already left, so that's not the ideal sentence. To put emphasis on the fact that they might have been there for some time, it would be useful to add another word like waiting.
I am not sure if they will have been waiting there by the time you