Helper function to append flag reasons

append_flag_reason(flags, idx, new_reason)